OP, the W_Healthbar
asset updates its own health. There is no code that calls it or updates it.
Look in Content/UI/Hud/W_Healthbar
and take a look at its Event Graph.
When the Healthbar constructs, it hooks into the Player Controller’s OnPossessedPawnChanged
event, and then immediately calls the OnPossessedPawnChanged
event with the current pawn.
In that event, it registers itself to receive OnHealthChanged
events from the Pawn’s Health Component.
From then on, any time the pawn’s health changes, the widget automatically updates itself.
When the player dies and respawns, the health widget automatically re-registers itself on the new pawn’s Health Component.