4.9.4.1 random - rand( x )

The rand function - rand stands for random - returns a random value based on the argument. This function works with floting point and vector arguments. The argument provides the range in which random values will be generated.

sphere.YPosition = rand( 1 );

This produced random numbers between 0 and 1.

This function does also work with two arguments which will be the maximum and the minimum random number generated:

sphere.YPosition = rand( -1, 1 );

This produced random numbers between -1 and 1.

This function does also work with a vector as argument. For this example the translation for the Sphere was switched to implicit velocity (also refer to the chapter "understanding vectors"):

sphere.Position = rand( vec( 1, 1, 1 ) );

This produced random vectors between 0, 0, 0 and 1, 1, 1.

The random function does also work with two vectors as arguments. For this example the translation for the Sphere was switched to implicit velocity (also refer to the chapter "understanding vectors"):

sphere.Position = rand( vec( 1, 1, 1 ), vec( -1, -1, -1 ) );

This produced random vectors between -1, -1, -1 and 1, 1, 1.

Xpressionist 3.5