I have 2 variables I don’t want them to go under 0.0 so I clamped them but when running the game they go under the minimum of the clamp, what have I done wrong?
var health = 100.0;
var hunger = 100.0;
function Update ()
{
hunger = hunger - Time.deltaTime/4;
if( hunger <= 5)
{
health -= Time.deltaTime/4;
}
}
hunger = Mathf.Clamp(hunger, 0.0, 100.0);
health = Mathf.Clamp(health, 0.0, 100.0);