Float is not matching my Hunger bar

having an issue where my float is not matching my hunger or thirst bar,
meaning “When the hunger or thirst bar is displaying 0 the float is higher then 0”
Just wondering what can I do to fix this problem?

If we talking about fractions like 0.00000084 or smth like that, then it most likely due to float imprecision. I would recommend using int under the hood, and if you need fractions you always can just multiply the value say by 100, and when displaying it to player use last two digits as fraction .00

Displayed Hunger: 54.09

Real Value: 5409


Trivia: this method was used in Stellaris for displaying resources in game. The value was multiplied by 1000.

So use an int instead of a float Ur saying? and that will give me better accuracy? this is whats happening now, the bar hit 0 but the float is not at 0.

I am decreasing the hunger by 0.02 out of 100.0

Sorry about the title being wrong. I meant the Hunger bar not health.

@UE4 ANSWERHUB moderator Can you please fix the title of this post it is bothering me it should say hunger not health lol

Thanks Man! Works Flawlessly Now.

That’s a bit too big number to be related to float precision problems, there may have been another issue. But I’m glad it works for you now :slight_smile: