Adding Global Variables

Next, let’s add the Global Variables that will help us track our player’s score and health.

Global Variables are data that persists across the entire game. As you move from scene to scene, the game engine remembers the value of global variables.

To add new global variables, head to the freestyle editor dashboard and select the “Global Variable” section from the left-hand sidebar.

On the Global Variable page, click “New Variable”. Change the Variable’s name to “Score”, and leave the type and default value as they are.

Repeat this process to add a Global Variable named “Health.” Set the default value of health to 3: that way, each player will start with 3 health, which will decrease as they play the game. When you’re all done, you’ll have two global variables setup.