UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials

engine.game Functions

float engine.game.getFTime ()

Returns time spent between a previous update and a current one. This function takes time scaling into account.

Return value

Frame duration in seconds.

int engine.game.getFrame ()

Returns the current game frame.

Return value

Frame number.

float engine.game.getIFps ()

Returns a scaled fixed frame duration.

Return value

Inverse frame duration in seconds (1 / FPS). If the game is paused, 0.

Obstacle engine.game.getIntersection (vec3 p0, vec3 p1, float radius, int mask, int ret_id)

Performs intersection to find if a pathfinding Obstacle is located within the cylinder between two points.

World space coordinates are used for this function.

Arguments

  • vec3 p0 - Source point.
  • vec3 p1 - Destination point.
  • float radius - Radius of the intersection cylinder.
  • int mask - Obstacle intersection mask. The obstacle is ignored if its mask does not match.
  • int ret_id - Return array, its components are:
    • ret[0]: intersection points (vec3), in the world coordinates.

Return value

Intersected obstacle.

Obstacle engine.game.getIntersection (vec3 p0, vec3 p1, float radius, int mask, int exclude_id, int ret_id)

Performs intersection to find if an obstacle is found within the cylinder between two points. The specified obstacles will be ignored.

World space coordinates are used for this function.

Arguments

  • vec3 p0 - Source point.
  • vec3 p1 - Destination point.
  • float radius - Radius of the intersection cylinder.
  • int mask - Obstacle intersection mask. The obstacle is ignored if its mask does not match.
  • int exclude_id - Array with excluded obstacles. These obstacle nodes are ignored when performing intersection.
  • int ret_id - Return array, its components are:
    • ret[0]: intersection points (vec3), in the world coordinates.

Return value

Intersected obstacle.

float engine.game.getNoise (variable position, variable radius, int frequency)

Returns a value calculated using a Perlin noise function.

Arguments

  • variable position - Point position (float or vec3).
  • variable radius - Allowed radius (float or vec3).
  • int frequency - Noise frequency.

Return value

Noise value.

Player engine.game.getPlayer ()

Returns the current player.

Return value

Current player.

variable engine.game.getRandom (variable from, variable to)

Returns a pseudo-random number within a given range, supports int, float, vec3, and vec4.

Arguments

  • variable from - Lower bound.
  • variable to - Upper bound.

Return value

Random number (type depends on arguments).

float engine.game.getScale ()

Gets a value used to scale a frame duration.

Return value

Value to scale the frame duration.

int engine.game.getSeed ()

Returns the seed for pseudo-random number generator.

Return value

Number used to initialize a pseudo-random sequence of numbers.

float engine.game.getTime ()

Returns the current time spent in the game. It is counted off starting from the world loading and does not take game pauses into account.

Return value

Time in seconds.

int engine.game.isEnabled ()

Returns a value indicating if the game is paused or not.

Return value

Positive integer if the game is not paused; otherwise, 0.

void engine.game.setEnabled (int mode)

Pauses or resumes the current game.

Arguments

  • int mode - Positive integer to resume the game, 0 to pause it.

void engine.game.setFTime (float ftime)

Sets the maximum rendering frame duration value, that is, it restricts the frame rendering rate to a fixed one. There is no difference if the real rendering FPS is lower than the fixed frame FPS. But if the real rendering FPS is higher than the fixed frame FPS, the engine will wait until the fixed frame time is over.

To remove fixed frame duration, use -1.

Arguments

  • float ftime - Frame time in seconds. -1 removes the FPS limitation.

void engine.game.setFrame (int frame)

Sets a specified game frame.

Arguments

  • int frame - Frame number.

void engine.game.setIFps (float time)

Sets a fixed frame duration. This function sets a fixed FPS that does not depend on the real FPS the hardware is capable of. That is, it forces constant frame time increments between rendered frames, used for animation/expression update etc.

This function is useful when grabbing the video reel with a fixed FPS value (for example, 25 frames per second). When this mode is activated, engine.game.getFTime() will return a fixed frame time value set with this function.

To remove fixed frame duration, use -1.

Arguments

  • float time - Inverse frame duration in seconds. The value should be reciprocal, for example: 1.0f / 25.0f. -1 removes the FPS limitation.

void engine.game.setPlayer (Player player)

Sets the current player.

Arguments

  • Player player - Player to set as current.

void engine.game.setScale (float factor)

Sets a value that is used to scale frame duration. It scales up or down the speed of rendering, physics and game logic. This function allows to create effects of slow/accelerated motion.

For example, if the scale equals 2, the rate of simulation of all effects (such as particles) speeds up to two times faster. As for physics, in reality it will be simulated with the same fixed physics FPS, but the number of iterations will be two times higher. (It is possible to scale the physics FPS separately via engine.physics.setScale() function).

This function scales both setIFps and setFTime. The default is 1.

Arguments

  • float factor - Scaling factor. The provided values is clamped within range [0;32].

void engine.game.setSeed (int seed)

Sets the seed for pseudo-random number generator.

Arguments

  • int seed - Number used to initialize a pseudo-random sequence of numbers. Non-negative value should be provided, as unsigned integer is used for it.

void engine.game.setTime (float time)

Sets a specified time for the game. The time is counted off starting from the world loading and does not take game pauses into account.

Arguments

  • float time - Time in seconds.
Last update: 2017-07-03