What does this guarantee?
health = Mathf.Clamp(health, 0, 100);
- Health stays within 0 to 100
- Health decreases every frame
- Health resets to 100
- Health can go negative
Clamp returns the value limited to the given range.
Play Game Dev ▸
health = Mathf.Clamp(health, 0, 100);