Download

3d widget health bar issues

So I have a health bar that appears over my AI character that visualizes his remaining health. The problem is that it only affects one of the AIs never another copy of the same blueprint. I can’t figure out how to tell it that each individual AI would have their own health bar. In example: (if attacked)

AI1: Health bar decreases as expected (But also effects AI2s bar)------AI2s bar will deplete but will not destroy the actor.
AI2: Health bar does nothing, but can be damaged and destroyed as intended.

Can anyone offer some advice on this?

As seen from the PIE, the print string shows both actors have different health values. but they share the same health bar

It is because on construct you are getting all the actor from class, and then, storing the value of the very first one (0) hence, all the bars uses the health from that particular actor. You need to specify the correct one (on create widget you could make the ID exposed as spawn)

So what I think is happening here is that you’re setting the “Actor Reference” variable twice. First you do it in “BP_AIChar”, then what happens is that the variable gets override in “UMG_TargetHealth”.

On Event Construct inside “UMG_TargetHealth”, the node “Get all actors from class” is taking all the “BP_AIChars” in the world and putting them in a array. So both of your AI characters gets the same reference (from the Get node) to the first AI character that spawned (if that makes any sense). That’s why when you hitting AI1 both the UMG updates.

To solve this you can:

  • Inside the “UMG_TargetHealth” set the variable “Actor Reference” to Exposed on spawn.
  • Spawn the Widget inside “BP_AIChar” to set the “Actor Reference” variable from UMG.

Or:

  • Just simply remove the Event Construct inside “UMG_TargetHealth”. (In hope that the “Actor Reference” gets set correctly inside the “BP_AIChar”).

Hope this helps you!

Best Regards

Must have simply just been exhausted attempting to reference the actors properly… but you were right all i needed to do was remove my reference from the widget and it pulled the reference properly. Thanks!