This page has been translated automatically.
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Setting Up Development Environment
Usage Examples
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
Double Precision Coordinates
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Math Random Functions

The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.

This class contains randomization functions.

float rand ( ) #

Generate a floating point random value in range [0,1). The function returns system rand() / RAND_MAX.

Return value

A pseudo-random number between 0.0 and 1.0.


Source code (UnigineScript)
forloop(int i = 0; 4) {
result is:
float: 0.510393
float: 0.638238
float: 0.406844
float: 0.407974

variable rand ( variable from, variable to ) #

Generate a random value in range [to,from). For vectors values are obtained per component.


  • variable from - From value. Can be the following types:
  • variable to - To value. Can be the following types:
    • int, long, float or double if the first argument is either int, float or double.
    • string if the first argument is int:
      • If a string is empty, it will equal to int(0).
      • If a string is nonempty, it will equal to int(1).
    • vec3 or dvec3 if the first argument is vec3
    • vec4 or dvec4 if the first argument is vec4
    • dvec3 if the first argument is dvec3
    • dvec4 if the first argument is dvec4
    • ivec3 if the first argument is ivec3
    • ivec4 if the first argument is ivec4

Return value

A pseudo-random number between from and to.


Source code (UnigineScript)
result is:
int: 1
float: 1.5561
vec3: 0.19138 1.81164 -0.688218

void srand ( int seed ) #

Set a new sequence of random numbers. Function calls system srand() function.


  • int seed - Seed value for system random number generator.
Last update: 2020-07-31
Build: ()