Mathf
Abs
Mathf.Abs(number)
Mathf.Abs(-3.0f) // returns 3.0f Mathf.Abs(2.5f) // returns 2.5f
if (Mathf.Abs(rb.velocity) < maxVelocity) { // do stuff }
Min
Max
Mathf.Min(value1, value2)
HP = Mathf.Min(HP, maxHP) // makes sure HP is never greater than maxHP
Mathf.Max(value1, value2)
HP = Mathf.Max(HP, 0.0f) // makes sure HP is never smaller than zero
Clamp
Mathf.Clamp(value, min, max)
HP = Mathf.Clamp(HP, 0.0f, maxHP) // HP is never smaller than zero or greater than maxHP