Add images when losing health

Hi everyone, I want to learn how to put visible an ‘X’ image when I lose certain amount of health. My health bar is set at 1.0 so I just want to show an ‘X’ image every time the character loses 0.2 of hp.

220569-unrealproblem.png

The first thing that comes to mind is to simply use the XXXXX as the background of the progress bar. But I think you want the Xs to pop only once a big enough health chunk has gone missing.

In this case, make a horizontal box with 5 images placed inside. The box would be the same size as the entire progress bar and is overlayed on top of it. The images are hidden. Once a chunk of health goes missing, unhide one of the images.

That should be pretty straightforward to set up. Let me know in case you have problems putting it all together.

I tried but nothing happened. I would appreciate it if you can help me.

Sure thing, have a look at this one:

Horizontal box with 5 images sits on top of the progress bar, the images can be hidden or made visible:

The code checks how much health there’s left in the progress bar and hides/shows the Xs:

I bound the health to the buttons so it’s easier to debug.

https://gyazo.com/729af247ba772edcf690d432c621b92e

Admittedly, if your health always goes out in 20% chunks, this is completely redundant and you could just use the progress bar’s background for this. If the health loss is more granular, and the Xs are supposed to show only when a large enough chunk has gone missing, then the above-mentioned method should work pretty well.

Good luck.

Thank you so much, It helped me a lot to understand better how it works. You are awesome, wish you the best!