General
Variables can be used to store data inside a graph or the whole Flowgraph project.
You can view them in the “Variables” window:
The main sections are:
- Current Graph:
Variables are only accessible in the currently viewed graph. - Manager Variables:
Variables are accessible in the entire Flowgraph project.
Variables can have the same types as pins, with some exceptions like “Table” and “Flow”.
You can use your variables in your flowgraph by using the “Get” and “Set” nodes. You can create them in different ways:
-
Pressing the Getter or Setter buttons in the “Variables” window.
-
Using any other possible method for node creation:
Things to look out for
Frame Delay
One thing to keep in mind when working with variables is that they are only actually set at the end of the frame. This means if you set a variable at the start of a graph and try to retrieve that new value at a later point, it will still hold the previous value of the variable, if there was one.
The “Variables” example project showcases how to handle this kind of problem.
If there are variables or general values that you want to pass on between states, you can use transition variables. You can read more about them on the Elements
page.
Multiple Setters
Another thing to be mindful about when working with variables is, setting a variable multiple times per frame.
Because Flowgraph allows for multiple active states and general branching, there is no way to ensure the order in which the values of the variable will be set. This can lead to unwanted behaviour and is why we do not recommend using variables in this way.
To give you more control over how your variable will behave in this kind of situation, you can choose from different options for “Merging” in the “Variables” window.
There are different options for the behaviour, depending on the variable’s type.