5. Variables

5.1. What is a Variable?

In Actimator, a variable represents data(numbers,strings,booleans). Each variable is associated with a name, these names are used to reference the data contained within the variable.

5.2. Global Variables

Press the plus button on the Global Variable Command to create a new variable.

Global variable

Type in the desired name for the variable:

Create variable

Global Variables can be accessed from anywhere in the game. You would use a Global Variable when you want it to be accessed by more than one entity.

Before we start using a variable, we want to set it to an initial value. You would normally set a variable in the On Create event:

Create variable code

Once set, the value contained in a Global Variable can be accessed by any other entity in the game.

Global entity variables

5.3. Local Variables

Press the plus button on the Local Variable Command to create a new variable.

Local variable

Type in the desired name for the variable:

Create variable

Local Variables can only be accessed by the entity they’re created in. The value of a Local Variable can be unique to each different entity, this is useful if you have several entities of the same actor but you want their variable values to change independently.

The following program sets the Local Variable Damage to 0 when the entity is created. When the entity collides with another entity, it’s damage is increased by 1. Finally, the entity is destroyed when the Local Variable Damage is greater than 20. All other entities of the same actor are unaffected and won’t be destroyed.

Local entity variables