Global variables
Global variables:
- are stored in memory for as long as the game is running
- can be accessed from any scene in the game
They're useful for storing data that the entire game needs access to at all times, such as the player's score. They're only deleted from memory when the player quits the game.
Creating global variables
- Open the project manager.
- Expand the Game settings panel.
- Select Global variables.
- Click Add.
- Enter a name for the variable.
- (Optional) Enter a default value for the variable.
- Select Apply.
Tip
Variable names should not contain dots (periods) or commas. We recommend using alphanumerical characters.
Using global variables in expressions
You can use global variables in expressions. The syntax depends on the data type of the variable. In the examples below, replace the placeholders in angled brackets with the relevant values.
Number
GlobalVariable(<variable_name>)
Text
GlobalVariableString(<variable_name>)
Structure
GlobalVariable(<parent_variable>.<child_variable>)
GlobalVariableString(<parent_variable>.<child_variable>)