format
typescript
Mathf.Clamp(val, left, right)class: Mathf
description
Limits the given value to be within the given minimum float value and maximum float value. If the given value is within the minimum and maximum range, it returns the given value.
parameter
| param_name | type | description |
|---|---|---|
| val | number | The given value. |
| left | number | The minimum float value. |
| right | number | The maximum float value. |
return
| type | description |
|---|---|
number | The float result between the minimum and maximum values. |
code example
typescript
// Returns the float result between the minimum and maximum values.
let result = Mathf.Clamp(5, 0, 10) // result = 5