If you create a new float variable you have the “Value Range” in the Details Panel. For example set it to 0 to 100, then your health will always be between 0 and 100. If you set it to 200, it will still be 100.
Hello all,
I need to know how to implement a limit to a float variable. I’m working on a health value and i need there to be a limit to how much my characters health can go.
How do i do this?
Search for Clamp node.
That looks fine so the problem must be somewhere else in the rest of your BP.
I make a max health float and a health float. keep them private and make a function that adds health, in that function check against max health when adding to health and don’t let health be greater than max health.
Thanks, but i have already tried this and it did not work.
that return value should be used to set the HealthP variable, and you need to do that every time you update the variable.
so if your player gets hit and loses 20 health points: you would get HealthP, subtract 20, then clamp the result between 0 and 100, and use that result to set HealthP.
It definitely works, so you made something wrong.