Variables
Last updated
Last updated
The variables window is located on the bottom left of the program. Variables are just containers that can store values to use them in different places in the editor.
To create a new variable we need to specify the variable name and type, then click the add button. Variables can be of the same type but can't have the same name.
Here is a short explanation of each variable type:
Int32: an integer value like 5, 30 or 100
Single: a decimal number like 2,5 or 9,3 (also commonly known as type float in programming)
Boolean: a value which can be either true or false (on or off)
String: a text value which represents a sequence of characters
Vector3: a decimal container storing three single values, commonly used for position (x,y,z) and working with spaces
Object: a generic value which can store whatever type it's passed to it. Can be used to store gameobjects, components, rigidbodies etc.
Each variable has a get and a set node, used to retrieve the stored value and to set the value to store. We can add a get or set node by clicking on the respective buttons and connect the nodes as usual.
Each variable must be set atleast once before using the get, else unexpected behaviour will happen. Always set the variable value before using it in the node flow.
Deleting a variable from the variables list will delete all of it's references from the graph editor.
Object variables works a little different from the other types. When an argument is connected to the input of an object get variable node, the output argument type gets automatically converted to the connected input type. Changing the input type after it has already been set once can produce unexpected behaviour, so it's always better to delete the variable and start with a fresh new one if the type of it needs to be changed.
Tip: always connect the same type when setting an object variable.