Returns a value clamped between the specified minimum and maximum.


clamp(val, min, max)

Argument Description
val The value to clamp.
min The minimum value to clamp between.
max The maximum value to clamp between.

Returns: Real.


With this function you can maintain an input value between a specified range.


speed = clamp(speed, 1, 10);

The above code will clamp the speed so that it never falls below 1 or goes over 10.

Back: Real Number Functions
Next: exp
© Copyright YoYo Games Ltd. 2018 All Rights Reserved