> For the complete documentation index, see [llms.txt](https://alexs-organization-34.gitbook.io/rednodeeditor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alexs-organization-34.gitbook.io/rednodeeditor/usage/variables.md).

# Variables

**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.**

<div align="left"><figure><img src="https://1176054007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F16eHiWrLvkdzPgx4n88e%2Fuploads%2FfiuNM8RBv0Z39vanJDW1%2Fimage.png?alt=media&amp;token=bd3d23c2-b1e2-4c44-839e-a7bcbbc1d264" alt=""><figcaption></figcaption></figure></div>

***

## How to create a new variable

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.

<div align="left"><figure><img src="https://1176054007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F16eHiWrLvkdzPgx4n88e%2Fuploads%2FgNnGZpbFRTiOCaYxhUFW%2Fimage.png?alt=media&amp;token=f56beb3f-fbdc-4b6f-9fc3-6bbf70cc5f68" alt=""><figcaption></figcaption></figure></div>

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.

***

## Using variables

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.

<div align="left"><figure><img src="https://1176054007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F16eHiWrLvkdzPgx4n88e%2Fuploads%2Fb8j3c0QL7svclWFcpFVD%2Fimage.png?alt=media&amp;token=6cf95cca-913e-4fbe-8bd3-97a0ddd01ee3" alt="" width="383"><figcaption><p>setting a <strong>single</strong> variable based on mouse movement</p></figcaption></figure></div>

<div align="left"><figure><img src="https://1176054007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F16eHiWrLvkdzPgx4n88e%2Fuploads%2FvcSzNw2Qf7gXh4vQrmZs%2Fimage.png?alt=media&amp;token=5dd0eee1-b34d-4587-a279-9f2c1a7fcc7c" alt="" width="563"><figcaption><p>using the same variable later in flow, when it already contains a value</p></figcaption></figure></div>

{% hint style="warning" %}
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.
{% endhint %}

{% hint style="danger" %}
Deleting a variable from the variables list will delete all of it's references from the graph editor.
{% endhint %}

{% hint style="info" %}
**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.
{% endhint %}
