Health UI: Adding a health bar
Author Patrick Kelly
Date 10/14/2022
The problem I ran into while
working on Island Defenders was implementing a blueprint that would update a
progress bar for player health on their heads up display. I was trying to get a
reference to the player actor and using it’s health to update a progress bar to
display player health to the player. The issue I ran into was getting a
reference into the blueprint widget. Even with that issue, the other problem is
when the player gets hurt, the blueprint widget would never receive the update
for player health changing.
I created a widget blueprint that used
a custom event that would take an input zero to one value to update the
progress bar. Eliminating the extra steps from the UI grabbing the player and
binding health updates and having to take in max health to produce a proper
zero to one value. From there, in the player controller, I placed an add to
viewport call on the health bar and bound the health bar update event to the
player’s take damage event. With this, the player was now able to see their
health as they took damage.
Comments
Post a Comment