Skip to main content

Time

world.time contains the following properties:

PropertyDescription
world.time.elapsedThe number of milliseconds the world has been running for, excluding time spent while the world was paused.
world.time.deltaThe number of milliseconds since the previous frame, excluding time jumps due to being paused.
world.time.absoluteThe number of milliseconds that have elapsed since the world was created.
world.time.absoluteDeltaThe number of milliseconds since the last frame, including large jumps of time if the world is resuming after being paused.

Start timer

const timeout = world.time.setTimeout(() => {
console.log('1000 ms have passed!')
}, 1000)

Clear timer

world.time.clearTimeout(timeout)

Intervals

Intervals (indefinitely repeating timers) work the same way:

const interval = world.time.setInterval(() => {
console.log('Another 1000 ms have passed!') // This will be logged repeatedly
}, 1000)