Skip to main content

Engine Tick Rate

Returns the value of the engine tick rate.

Engine Tick Rate block

Description

The Engine Tick Rate block returns the value of the engine tick rate. This is a code block part of the Interface drawer.

Usage

Use Engine Tick Rate to read the current simulation speed. This allows you to compensate for changes in engine speed by adjusting movement values, ensuring consistent behavior regardless of the tick rate setting.

Syntax

Input:

  • None

Example

In this model of a forest environment, when the engine speed is adjusted, the directional light will rotate faster but the speed of the organisms inside will be unaffected. This is because every movement block (moving forward and rotating) is multiplied by a 'speed' trait which is set to be higher when the engine tick rate is slower and lower when it is faster, making up for changes to the engine speed. Instead, to change the speed of the animals you can adjust the speed slider.

Engine Tick Rate example code 1Engine Tick Rate example code 2

Notes

  • Returns a numerical value representing the current engine tick rate
  • Useful for creating speed-independent animations and movements
  • Can be used to normalize agent behavior across different simulation speeds
  • Clock - Returns the current clock value
  • Set Clock To - Sets the clock to a specific value