Announcement

Collapse
No announcement yet.

Health Bar Needs to hit 3 times before updating

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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

    https://i.stack.imgur.com/XXPdE.png

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

    here's where I implement it

    https://i.stack.imgur.com/67e45.png

    From the `apply damage` function in UE I get the damage

    #2
    Originally posted by Ginxx008 View Post
    I'm having trouble why my Widget Health Bar is not updating not until I hit it 3 times first.

    Here's my blueprint

    https://i.stack.imgur.com/XXPdE.png

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

    here's where I implement it

    https://i.stack.imgur.com/67e45.png

    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...
    Check out Zof ( puzzle game ) on Steam:

    https://store.steampowered.com/app/1414480/Zof/

    Comment


      #3
      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

      https://imgur.com/a/mvX5Jk0
      Last edited by Ginxx008; 03-06-2020, 06:23 AM.

      Comment


        #4
        Anyone please.

        Comment


          #5
          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.

          Comment


            #6
            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)

            Click image for larger version  Name:	exampleprogressbar.PNG Views:	0 Size:	171.9 KB ID:	1731735
            Attached Files
            Last edited by Deathstick; 03-11-2020, 05:09 PM.
            Indie Dev - Whiskey Cat Softworks
            Currently developing a colony survival game!

            https://twitter.com/WSoftworks https://www.facebook.com/WhiskeyCatSoftworks/

            Comment


              #7
              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.

              Comment

              Working...
              X