Beginner's guide to Construct 3



Features on these Courses



1,206,503 visits, 3,534,916 views



This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Keeping score

Let's have a score so the player knows how well they've done. We'll need another variable for this. You might think "lets put the score as one of the player's instance variables!". That's not a bad first idea, but remember the value is stored "in" the object. If there are no instances, there are no variables either! So if we destroy the player, we can no longer tell what their score was, because it was destroyed with the player.

Instead, we can use a global variable. Like an instance variable, a global variable (or just "global") can store text or a number. Each variable can store a single number or a single piece of text. Global variables are also available to the entire game across all layouts - convenient if we were to add other levels.

Right-click the space at the bottom of the event sheet, and select Add global variable.

Adding a global variable

Enter Score as the name. The other field defaults are OK, it'll make it a number starting at 0.

Adding a Score global variable

Now the global variable appears as a line in the event sheet. It's in this event sheet, but it can be accessed from any event sheet in any layout.

The 'Score' global variable

Let's give the player a point for killing a monster. In our "Monster: health less or equal 0" event (when a monster dies), click Add action, and select SystemAdd to (under Global & local variables), and choose Score with a value of 1. Now the event should look like this:

Event adding to score

Now the player has a score, which increases by 1 for every monster they kill - but they can't see their score! Let's show it to them with a text object.

Disabled Comments have been disabled by the owner.