unity docs mathf.clamp code example
Example: mathf.clamp unity
//stops "value" from getting smaller than xMin and bigger than xMax.
float value = Mathf.Clamp(value, min, max);
//stops "value" from getting smaller than xMin and bigger than xMax.
float value = Mathf.Clamp(value, min, max);