HealthBar switching animations

My healthbar is a sprite and uses a flipbook; I have added 2 of the healthbars one not visble while the other one is, my main problem is getting the 1st one to switch and the other to not switch is their anyway to get them to set one visible while the other one takes over?

Could you clarify a couple of things:

  • are there 2 healthbars in the same widget?
  • is the >=20 the condition that is supposed to flip their visibility?
  • are they supposed to be mutually exclusive - only 1 can show at one time?

I see that you’re working with widgets above, nothing above is referred to as a healthbar so not sure how the whole thing is set up. Do you mean those images? And the title mentioned switching animations?

I hope you can see how this can be confusing to someone who does not know what you’re up to.

Yes the 2 healthbars are in the same widget

The condition >=20 is supposed to filp the visibility, so if the health is > or = 20 then the first images will disapear and the second image shall apear

Yeah only 1 should be able to show at a time so the player can see where their healthbar is at, meaning if the condition is met then the healthbar changes animations and is closer to death

I appoligize for not naming them (I should get into the habit of it) as for the question yes the images are refering to the healthbar, I wanted the health bar to be made from a flip book so the images are animated but I am stugguling to get the condition to work as when the player health drops the animations/images do not switch visibilty and the first healthbar disapears

If you need to me to provicde more coding/images to get a clearer picture let me know

In your example:

  • there’s no need to cast - see the blue note on the Cast To uic node
  • it’s set up to not show / hide anything when health is high and hide both when health is low:


I believe it should be closer to :

  • The only reason im casting to uic is to get my targets
  • The tutorial I was following was only for a health bar changing color so it didnt include trying to switch the image when the condition was >= 20

I tried what you did but still shows the 2nd image and isnt hidden

I also decided to chage my health to a float to follow it closely

I belive that I should try to make both health bars separate and just use a call function so it gets rid of the first one and the second one can do its own thing until it gets its health back.

• why are we using Get All of Class?
• you really do not need to cast - have a look at the blue note (not important, here, though)
• if the node in the bottom right corner ever executes, your game will crash, you looped the execution wire back

The snippet I posted should work, if it does not, the issue is elsewhere. Look into why the Get All is used here. If you have only 2 health bars to work with, it makes no sense.