Making the Game: Game Over, Game Paused

Simulation was mostly feature complete. There were puzzles, hazards and collectibles. One of the big, important missing features though was death. The player's health went down, sure, but it could keep going down indefinitely. Well, no more!

Game Over


When the player reaches 0 lives, the Game Over Screen now appears. From here, the player can either choose to restart from the beginning or to quit the game. Simple and effective, I'd say.

Implementation


The previously created "Lose a Life" event now checks whether the current health is less than or equal to zero. If it is, the "Death" event begins. This turns off player control through a newly added "Can Control" bool (when the bool is false, all control the player has is gone). I set the Player Controller's Show Mouse Cursor bool to be true, so that the player can interact with the "GameOver" screen. Then, the screen itself (or an instance of its widget, rather) is created and added to the viewport. Finally, the game is set to paused (this is built-in functionality in Unreal), which means all actions in-game are stopped. However, clicking on buttons in the UI is still possible.


The code on the "GameOver" is as simple as they come. When either button on the screen is clicked, an On Clicked Event is fired. One of them uses the Open Level node (kinda like Scene Manager's Load Scene in Unity) to open an instance of the current level, effectively restarting the game (as it only has the one level). The other uses the Quit Game to... well, quit the game. It's quite similar in functionality to Unity's Application.Quit(), really.

A Simulation, Frozen

Another thing I added in is a Pause Menu. Though not a necessity in and of itself, being able to pause a game and walk away from it is always welcome.


Simulation's pause menu is fairly simple. It can be brought up by pressing either the Escape or P buttons on the keyboard. There are only three options available: one to resume the game and another to quit out of it. Pressing Escape or P again will also close the Pause Menu.

Implementation


After setting up a new "Pause" Input Action, I created a "Pause Menu" widget. In essence, it's identical to the Game Over one, with an extra On Clicked Event to resume the game.


I put the InputAction event for triggering the Pause Menu in the FirstPersonCharacter blueprint. This is also where the "Pause Event" itself resides. It's quite similar to the "Death Event" in many ways. The most fundamental addition here is the FlipFlop node, which determines whether a Pause Menu is added or removed instead.

Having finished these, I will spend the next few days working on a "Main Menu" or splash screen, as well as adding polish and extra quality across many different areas in the game. Thanks for reading, see ya then!

Comments

Popular posts from this blog

Making the Game: A Simple Puzzle

How to Keep Blueprints (Mostly) Readable

Making the Game: Final Touches