Api > Mathf > Clamp()
Clamps the given value between the given minimum float and maximum float values. Returns the given value if it is within the min and max range.
Parameters:
Name |
Type |
Description |
value |
number |
The floating point value to restrict inside the range defined by the min and max values. |
min |
number |
The minimum floating point value to compare against. |
max |
number |
The maximum floating point value to compare against. |
Returns:
type |
Description |
number |
The result between the min and max values. |
Usage
---@type number
local value;
---@type number
local min;
---@type number
local max;
local val0 = Mathf:Clamp(value, min, max)