Course Content
Unreal Engine FPS Game
Unreal Engine FPS Game
Creating Health Variable + Functions to increase or decrease it
In this chapter, we will take a look at events BeginPlay
and Tick
, as well as functions and variables. Coupled with that we will implement the health of the character by creating a variable, and a function that we can call to reduce the health which resembles taking damage.
Variables are elements that hold information of a certain type. For instance, a variable of type Integer holds a whole number, and a variable of the type Boolean holds a true or false value.
To create a variable, click on the + sign in front of Variables in the left hand side panel called My Blueprint, give it a name and choose its type as shown in the video.
Events are instructions that we can call in run time to have our blueprint do something. The main two built-in events that we look at in this chapter are Event BeginPlay and Event Tick.
- Event
BeginPlay
fires off as soon as the blueprint is spawned into the game while the game is running. Event BeginPlay fires off only once. To create a BeginPlay you can right click somewhere in the Event Graph that is not occupied and type in “BeginPlay” and choose Event BeginPlay. - Event
Tick
also fires off as soon as the game starts, but will continue firing off continuously. To create an Event Tick, right click in the graph and search for Tick and choose Event Tick.
Functions are similar to Events, they perform a set of instructions. There are some differences between Functions and Events.
Note
In functions, there is no concept of time, so nodes such as Delay do not exist in a function.
To create a function, click on the + sign in front of Functions in the My Blueprint panel.
Thanks for your feedback!