Advanced Blueprint Concepts 543
FIND ON THE WEBSITE
To find updates to this tutorial and u pdated instructions about its implementa-
tion on other UE 4 versions, please visit the book’s companion Website at:
http://www.RVRLAB.com/UE4Book/
TUTORIAL 8.8 Adding t he Score
In this tutor ia l we will establish our game start/end conditions. We will also
implement a save/load mechanism to allow for the game to retain th e highest
score by the player.
ESTABLISHING ACTIVE GAME STATE
The first thing we need to do is set up our game to start and end based on the
Game Timer we created in the previous tutor ia l. Once this is done, we will be
able to check if the c urrent high score has been surpassed at the e nd of the game,
and update it if necessary. When the game is loaded up f or the first time, we will
check if a save file exists, and load the data f rom this file to be displayed on the
HUD.
1. First, open up the level blueprin t.
2. We need to add a Boolean variable that we will use to d etermine if the game is
currently active or not. To do this, perform the following tasks:
a. Create this variable and give it the name IsGameActive.
b. With the IsGameActive selected, go to its Details window, set its default
value to True by checking the box.
3. For our purposes, we will define an ac tive game state to be a ny state where the
GameTimer is not equal to zero. We simply n eed to check the GameTimer variable
to see if it is equal to zero, then act accordingly. Perform the following tasks:
a. Find the Timer Logic network that we created in the p revious tutorial.
b. Drag a wire off from the Update Timer HUD Event function c all, and add
a Branch statement.
c. Pull a wire off from the GameTimer variable and search for a == (two equal
signs).
d. Connect the ou tput of the == to the Condition in put of the Bran ch variable.
This will check if this variable is equal to the value 0.0.
e. Drag a Set for the IsG ameActive variable to the right of the Branch state-
ment.
f. Connect the True outp ut of the Branch to the exec(white) input of the Set
for the I sGameActive variable. Make sure that the checkbox next to the
IsGameActive is unchecked. This will set our IsGameActive to False (see
Figure 8.42).