Dynamic enemy healthbars
Another thing that you'll often see in games are healthbars for enemies that will appear over their heads, changing as the game is being played. In this recipe, we will learn how we can do what we've learned from the previous recipe and apply it here.
Getting ready
Before we start working on this, we need to have a project created and set up. Do the previous recipe all the way to completion.
How to do it…
Of course, to actually have enemy healthbars, we will need to actually have an enemy, so let's get that implemented first:
Go to the Content Browser tab and then to the
ThirdPersonBP/Blueprints
folder. Right-click on theThirdPersonCharacter
object and then select Duplicate and name the duplicated objectAI
.Double-click on the blueprint to open up its EventGraph. We actually don't need any of the previously-created stuff in Event Graph, so select all of the Unreal-created content and then delete it. Do note that we do have the
CurrentHealth
andMaxHealth
properties and...