How can I best implement floating health bars for my multiplayer game?

I want to implement a floating health bar system across many actors, such as other players, NPCS and destroyable static objects, but I’m not sure how to go about doing it.

I’ve already got player health in my HUD, but I’m trying to figure out how I can implement a system so that other players or objects only show health to the player who applies damage to them (If I can do so with the InstigatorController in the ReceiveDamage() function even better)

Does anyone have a solution? I’m guessing the client who does the damage would have to create the widget, but I have no idea how I would go about anchoring that widget to the actor who the health belongs to and I feel like I’m travelling through quite a few layers (I have to get the other clients health information to the client who owns the widget so they can build it on their screen).

Any pointers, videos or resources welcome. Thanks

Edit: Just showing the implementation of player health


e

The widget component should exist permanently.

When damage is received on a client, if the instigator is a locally controlled player controller, then set the visibility of the widget component to true.

2 Likes

Makes sense but I’m still practically pretty confused, I haven’t worked with widgets a lot. I’ll share my C++ so far.

Function in widget to update health progress bar:
image

Setting up my widget component in my character BP:

Trying to cast to my widget class when damage is taken to update progress bar (doesnt work):
image

I found a solution within blueprints. It lets me cast to the widget there for some reason.

image

I still don’t fully understand why, I think I missed a intermediary function in my C++? Not sure but I’ve spent around 6 hours on getting this little health bar to work so I’m v happy.

edit: Still wondering how I get it to show for the attacking player, but not the player being attacked. I already have a HUD health bar and it clogs up the screen a bit for the victim

edit2: nevermind I managed to do this with a client RPC to hide after multicasting the visibility