Enemy Health Bar not Binding

Hello Everyone!

I have read all the questions and replies here about this and yet still no answer. I am trying to bind a widget health bar to my enemy AI. It appears above his head, facing camera, all good. It does not display the health. My hero displays his health, no problem, so I am assuming it is how I am approaching the Event Graph in the Widget BP. I have a feeling it has to do with Object being cast to CastToZombieCharacter. Object is a public variable. Here are some images. I think its a really easy step I am missing, if anyone could point it out, that would be awesome!

What are you assigning to Owner?

  • I am assuming that Owner in the Event Construct event is the result of a hit. You are then storing a handle to this object for later reference, however you are not using this handle in the “get percent zombie health” function. Instead of calling it “owner”, how about something less ambiguous like “focusedActor”.

Have you considered creating a base class (or interface) that handles every characters health and damage mechanisms?

  • Any class, such as your zombie class that extends this base class can be handled by the same code. Instead of storing a variable “ZombieCharacter” just store the base class. The implementing class can use public means to change any desired behavior differences. Importantly, your blueprint will not get polluted with numerous specific actor types.

Once you have cleaned up your parameter names and leveraged a base class for commonality, you should just have to connect your target hit result to your players HUD “Event Construct” event. Next, set up an event tick that queries the health of your “focusedActor” that will update itself accordingly.

  • You’ll also want to consider changing target, and target validity checks along the way. I assume that there will be many targets eventually.

Cheers.

That sounds excellent! I do have an Interface, “IDamageable”, but a little confused about its use. I’ll implement what you said and let you know how it comes out. Thanks for taking a few minutes to explain it!