UMG Healthbar is shared for multiple enemies

I have created a health bar in UMG for multiple enemies. It works great for the first enemy. The problem is that the other enemies share the same health bar. So after the first enemy dies the other enemies have their health bar already depleted.

I’m sure I’m not going about this the right way. So my question is what would be the best method to create enemy health bars that can work for multiple enemies and be independent of each other?

Thanks!

I would think each enemy would have to instantiate their own UMG Widget in their start up? so in the enemy blueprint there’d be a “Create Widget” in their construction or something like that - sorry I don’t have the engine open right now but it’s got to be something like that - hope that gives you an idea :wink:

How are you creating the widget? Is it a Widget Component in the enemy blueprint?

Where is the value that controls the health bar status?

Can you show a screenshot of the graphs that modifies the health bar (both where the health var on the Pawn is modified, and where your Widget does something with it)?

Each instance of that Pawn has its own instance of the health bar and health variables, so its probably a simple error somewhere in your graph.

I actually got the health bars to act independently now. The problem was the the health bar for some reason was dictating the health of the pawns, instead of the other way around. It was an issue with my graph and after I changed the order of some variables it started working as it should.

Even though they are acting independent the health bar is not updating as often as it should. For instance I kill the first pawn and move to the second pawn. The 2nd pawn has its health bar depleted until I cause some damage and then it adjusts and acts as it should.

Anyway, I’m going to play with it some and see if I can’t figure out how to update the health bars properly. Thanks for the responses JParent and GeeksGoneBad. I do appreciate it.

After looking around at different forums, I came with the solution that worked for me (Referencing this forum: Enemy 2D Health Bars - Programming & Scripting - Unreal Engine Forums).

On “event tick” I fire my “HealthBarUpdate” function, which updates the percentage of the enemies healthbars. The healthbar is a 3D Widget in the enemy blueprint (picture below).

http://puu.sh/ts2yM.jpg

This is how it looks above my enemy (picture below).

http://puu.sh/ts2E6.jpg

Hope this helps! :slight_smile: