Make Healthbar dissapear if there is no change

So i want the Healthbar to dissapear if there is no change for a few seconds, but I havent been able to figure out how to do that. I searched for this on the Internet but found nothing. I hope you can help me out.

Hey,

I assume you are using Blueprints.

  1. Make OnChange dispatcher, function or event.

  2. Call it when your healthbar changes.

  3. Make disappear animation (or set visibility to hidden but this will be ugly)

  4. In Onchange make retrigerrable delay (It will execute after some time (disappear time) and if your health changes it will start counting again.)

  5. After delay finishes call this animation from point 3.

Przemek2222’s way is not bad and can get the job done but there is an easier way to do this.

  1. In your UI make sure that your health bar “is variable” is checked in the top right corner.
  2. Then in your character blueprint (or preferably your character base), when you begin play create your player hud widget,
  3. Promote that to a variable
  4. Then add it to viewport
  5. Now grab that variable and get your health bar from it
  6. Get your render opacity from that
  7. And either set it to zero so its not there when we start
  8. Or just put a delay in to leave the bar up for a few seconds and then set opacity to zero (kind of abrupt though)
  9. Or (my personal favorite) add in a timeline, add a float track to it and set it for however many seconds you want it to fade out for.
  10. Then put in your render opacity
  11. From that value do a lerp between A at 1 and B at 0 and connect the alpha to be that float track we created.
  12. Now when you press play the bar should show up for a few seconds, depending on that delay amount you set, and then disappear over time (set by our timeline) from full visibility to no visibility.

Now if you want to be able to use this in several spots simply make a custom event and name it whatever you want for clarity and drop everything from the timeline forward into this event. Then in begin play instead of doing that long list of nodes (which really isn’t that long) just call that new event you made. Now when you go to take damage just grab your hud variable we set earlier get the health bar and set opacity to 1 so we can see it. Then after damage has been done call that custom event again to get it to fade away after a bit.