Download

Health Bar Needs to hit 3 times before updating

I’m having trouble why my Widget Health Bar is not updating not until I hit it 3 times first.

Here’s my blueprint

my EnemyHealth variable is set to 100 and HealthPercentage is set to 1 .

here’s where I implement it

From the apply damage function in UE I get the damage

It’s because you’re only taking damage if the mesh animation isn’t playing…

I tried putting it directly to the event damage and yet it still like i need to hit 3 times before the fill of the progress bar react

here’s an image for you to visualize sir

Anyone please.

A few questions here:

  • What do you mean you need 3 hits? Do this hits cause damage to the character even though the widget does not update?
  • Why not just binding the character or pawn’s health to the bar?

It would help a lot if you could share more info.

ClockworkOcean’s note was correct, you’d have to change your structure so the take damage function is before your is animation playing if statement, or potentially better, use a sequence node so your visuals don’t interfere with your actual damage statements.

The best way to update a widget to display the health correctly is as Dacabad said, bind the percentage of the progress bar to read from the EnemyHealth variable. Also your progress bar is most likely not updating until the third hit because the value of “1.0” is what makes the progress bar widget look full, 0 is empty. Your enemy health is probably still higher than 1.0 after dividing by 100.

Instead of dividing by 100, I’d suggest you use the Map Range Clamped node in your widget where the variable EnemyHealth is being bound to the progress bar. See:
https://docs.unrealengine.com/en-US/…ped/index.html

Input the EnemyHealth into Value. Leave In Range A at 0 and Out Range A at 0. Put the Max Health that your enemy can have at In Range B. In Out Range B put 1.0. Plug the return value of the map range clamped node into the return percentage of your progress bar and that should do the trick.

I’ve attached an image of the setup of a binded progressbar in my own game that you can alter to fit your needs, which illustrates how to use map range clamped. HealthToDisplay being a local variable so the function will always return something even if the actor reference it’s trying to read no longer exists (defaults to 0 if the reference check returns NULL)

It’s already solved because the problem here was when I put my progress bar and resize the x value it doesn’t perfectly fit on my 100% health what I tried was put the progress bar as it is (the default size) then try again my health bar and now every hit is updating the healthbar.