Get a Negative Number to Display on the MetalRedBar

I’m trying to make it so that if the player takes more damage than they have health, their health bar will display a negative number.

But it only goes to 0 and not any lower. This is on the ‘Health Bar Tutorial’ with the only changes being visible in the last pic.

Does anyone know how to make it work?


You can see on the left side that the damage works. Every time the die rolls, whatever number it lands on is how much health is taken away.

However, on the right side you can see that the health bar shows ‘0/6’ instead of ‘-2/6’ like I want it to, even though the player took 4 damage while only having 2 health left.

I never used resource bars but i think they are not meant for negative values
OR you need to set minimum value to negative if that is possible

One way to do it would be to hide original text of resource bar
I think it had such option
And just place there some text object and now you can display whatever you want

Or if there is action to set minimal value of resource bar you could check if player health is less then 0 if so set bar minimal value to player health

9
Using a text object almost worked.
It does display the negative values like I wanted, but now it doesn’t show the max health.

So instead of ‘-4/6’, it just shows ‘-4’.

How could I get it to also display the max health?

I considered just making another two text objects, one for the ‘/’ and the other for max health, but I was wondering if there was a way to have it all work with just one text object.

ToString(Player.Health::Health())+"/6"

Or smarter thing to do would be to make variable called MaxHP and set it to 6 and now you go with

ToString(Player.Health::Health())+"/"+MaxHP

Or in case above would give error
ToString(Player.Health::Health())+"/"+ToString(MaxHP)

And now if you ever need to increase max health of player you would not need to change anything in text object
Unless your player will never have more than 6 HP then stick to one with “/6”

That works perfectly!

I wound up going with

ToString(Player.Health::Health())+"/"+ToString(Player.Health::MaxHealth())

but it works exactly how I wanted it to.

Thanks for the help, Zero, it’s much appreciated.

1 Like

Im not using health behavior so i forgot it have max health value
So yeah in your case variable would be useless and your approach makes more sense