How can I keep my player health at 100% even if I have 2500 health, numerically (Not a fill bar)?

Its prolly a silly question but I suck at this lol. All I want to do is display Numerically how much health I have no matter if my health is set at 10, 200, 3500. If this is answered elsewhere just point me in the right direction. TIA! Oh and not a split number ie: 000/000.

So not a fill bar but still a UI reference right? I found this video on YouTube Unreal Engine - Damageable Health Bar Tutorial (1/2) - YouTube

This wasn’t what I meant. What I want to do is have my health the text part of this pic


show 100% even if I set my current health to be 2000 or 50% if I take 1000 damage. etc. I do like what he was doing there though, and I appreciate your time thank you.

1 Like

For leading zero:

https://forums.unrealengine.com/t/hud-add-0s-to-unused-number-places/341001/11

That is just a pic from my hud, Im not looking for leading zeros. Just looking to have my health read 100% even if my health is 2000 or 50% if I take damage and its 1000.

Hey @Xoremus,
If you have a health bar max value, you should try setting that to the player’s max health, and update when the player’s health updates. To show the percentage though, you’ll eventually need to divide the players’ current health by its max.

Hope this helps a bit!
-Zen

1 Like

You could use the ‘Map Ranged Clamped’ node. You input your current health value, then the min and max the health can be (ie 0 - 2500) into the In Ranges, then if you want to show only 0-100, for the Out Ranges, just put in exactly that. The output will always be between 0-100 regardless of the max health you decide to use.

you should refamiliarize yourself with percentages. I am sure youtube has plenty of math tutorials for that.

As mentioned you can use map range nodes, but if you will do much programming it’s gonna pay back dividends to brush up on that basic math stuff.

All you’ll need to do is have your max health and current health variables, and divide. That will return the percent.

I understand that Current/Max = 1 or 0, I want it to be 0 to 100 and as mentioned it needs to work in such a way that if my max health can be 2000 reading 100% or if I take damage down to 1000 it reads 50%. I want my text to read 100 or 50 or 20 depending on the damage I take. The map ranged seems to be the way to go for this to work.

I guess i dont understand. Seems like you just want to know the percentage of the max health that the current health is.

If you don’t want it to read 0.5 or 0.2, you just mutiple by 100.

The formula you’re looking for is: Round( CurrentHealth / MaxHealth * 100).

First get the percentage of current health compared to max health.
For example, 1000 current health divided by 2000 max health is 0.5.

Percentages are scaled from zero to one. To get it scaled from zero to a hundred we just multiply the number by a hundred.
0.5 times a hundred is 50.

Then, since you don’t want the fraction when dividing unequally (like 100 out of 300 is 33.33333etc) we round it so it becomes just 33.

This is how you would do it in BP:

Thank you! this makes total sense just over thinking things.