Documentation

Learn how to use NodeCanvas

Mapping Sub Graph Variables

Every graph in NodeCanvas has its own local Blackboard variables which are accessible only from within that graph by default. However, it is usually desirable especially when using a graph as a sub graph within another, to be able to access the sub graph local variables. The first step to allow a local graph variable to be accessed, is to make it “Exposed Public” from within the variable gear context menu.

Sub Graphs

Within the inspector of every sub graph node (Sub Behaviour Tree, Sub FSM, Sub Dialogue Tree), you have the option to map any “Exposed Public” variable of the sub graph to any other variable of the parent graph (considering the types are assignable of course). In the following image, the variable named “myFloat” is part of the Sub Behaviour Tree. However because it is made “Exposed Public”, it is shown in the inspector possible to be mapped to a variable of this parent graph.

By default, no mapping is enabled, however mapping a variable can be done with the respective buttons on the right side of the variable. A variable can either be set to Write In, Read Out, or both. When either Write or Read is enabled for a sub graph variable, you have the option to link that sub graph variable to another variable of the parent graph, however if Read Out is enabled, linking to variable is mandatory, since with Read Out enabled it means that the value needs to be stored somewhere.

Writing In is done every time that the sub graph is enabled (which depends on what type of graph we are using the sub graph), while Reading Out is done continuously while the sub graph is running (this is done with binding rather than any update loop for performance).

Root Graphs

When a local graph variable is made “Exposed Public” and that graph is the root of a GraphOwner (BehaviourTreeOwner, FSMOwner, DialogueTreeController), the exposed variable is instead displayed in the inspector of that Graph Owner component through which you can similarly override the exposed variable. However in this case and since there is no other variables to map to (since it is the root graph), there is only the option to override the exposed variable with a direct value. In the following example image, the assigned root Behaviour Tree has two exposed public variables: “myGameObject” and “myString”. In this case “myGameObject” is left untouched, while “myString” has been overridden.

Any changes made in an overridden exposed variable (which from now on are considered to be a parameter of the GraphOwner), and for as long as the graph is enabled, are made in realtime. To get/set the overridden exposed parameter of the GraphOwner in code, the GraphOwner API can be used and more specifically the “GetExposedParameterValue” as well as the “SetExposedParameterValue” methods respectively.

Yes No Suggest edit
7 of 8 users found this section helpful
Suggest Edit

© Paradox Notion 2014-2024. All rights reserved.