Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Gameover Logic | Gameplay Logic
Unreal Engine FPS Game
course content

Зміст курсу

Unreal Engine FPS Game

Unreal Engine FPS Game

1. Unreal Engine Introduction
2. The Character Blueprint
3. Enemy Blueprints
4. Level Design and Aesthetics
5. User Interface and Sound Effects
6. Gameplay Logic
7. Packaging for Windows

bookGameover Logic

In this chapter we are going to set up the conditions for gameover when the player runs out of health! There are several ways of doing this. For example, you could set up a new function that checks the player health and shows the Gameover Widget once the health is less or equal to zero, and then use an Event Tick to constantly call that function.

However, that is not very good practice! The reason for that is that you should avoid using Event Tick when you can as it fires constantly and if you have a lot of instructions that run using an Event Tick, you will increase the demand on the computer and the processor, especially if the calculations are complex. With that said, despite these calculations not being particularly complex, we will implement this functionality directly into our Take Damage function.

So let’s open the TakeDamage function that we created in the FirstPersonCharacter early on in this course. Here, we can check if the value of the PlayerHealth variable has dropped to zero or lower directly after updating the value! This is good practice.

So at the end of the function where we have our Set Player Health, drag out of the green pin and look for less or equal to. Let the other integer be 0 and using a branch, check if the value of PlayerHealth has dropped below 0 as shown below.

Next, get the Player Controller and set the input mode to UI only and set the Show Mouse Cursor to True. This way, we make sure that the player can click on the buttons that we have placed in the Gameover blueprint.

Create a widget and look for WBP_Gameover and add it to the viewport. Lastly, look for the Set Game Paused node and check the box so that once the Gameover screen is shown, the game is also paused! That is it!

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 6. Розділ 3
some-alt