Adding the game timer
The game timer serves the purpose of counting down and restricting the duration of a game session. To make the timer work, follow these steps:
- Introduce a new float variable named
Timerinto theAPangaeaGameStateclass. - Ensure that the
Timervariable is capable of being replicated to inform clients about changes to the timer’s value. - Define a C++
Delegatethat can be linked to Blueprint events, enabling the execution of an event function whenever the timer’s value changes. This function will update the display for the countdown. - Create a custom event on BP_HUDWidget and bind the customer event to the C++
Delegate. In the meantime, link the custom event to an event function, which will be responsible for updating the display. - Count down the
Timervariable within the Level Blueprint of TopDownMap. - Display the Game Over window once the timer reaches 0.
Let’s get started!