clamp

Returns a value clamped between the specified minimum and maximum.

Syntax:

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.


Description

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


Example:

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