Edit initial variables

You can declare variables and their initial values for any variable type: global variables, scenes variables or objects variables.

Variables can be used in events without declaring them, but declaring variables allows to attribute of initial values and declared variables are more efficient than not declared variables when used intensively in events.

Basic changes

Use the first button of the toolbar to add a new variable. You can then change its value by double-clicking on it. The toolbar can also be used to reorder the variables, delete the selected variable, or modify the name of an existing variable.

Finding undeclared variables

For scenes and global variables, you can scan the project for undeclared variables using this button:

After clicking on it, GDevelop will scan the project and will present you with a list containing the name of variables used in the events but not declared on the list. You can then check in this list the variable you want to be added to the already declared variables.

Declaring structures

GDevelop supports the use of structures: structures are variables that contain other variables, called the child variables, instead of a single value or text.

You can add a child to a variable by making a right-click on it, and choosing Add a new child: The variable will be transformed into a structure and the child variable will be added.
In the events, you can access a child variable using this syntax: Variable.ChildName. You can also enter a text expression instead of the child name using brackets : Variable.[“Child”+ToString(Variable(Index))]

You can learn more about structures in this tutorial.