Skip to main content

Timers

The timer module allows you to set up a script that runs after a certain duration or repeatedly at regular intervals.

This is useful for controlling timed events, delayed actions, periodic animations, or any game logic that needs to happen on a schedule rather than every frame.

Setting Up a Timer

Use the Attach Timer Script event to create a timer. You specify:

  • Timer slot — Which timer to use (selected by number).
  • Duration — How long to wait before the script runs, in seconds.
  • Script — The events to execute when the timer fires.

The timer fires repeatedly at the specified interval until you remove it.

Timer Slots

By default, there are 4 timer slots available. You can increase this in the Maximum Elements settings.

Each slot is independent — you can have multiple timers running simultaneously with different durations and scripts.

Managing Timers

Waiting

The timer module also includes two useful waiting events:

  • Wait — Pauses the current script for a specified duration (in seconds).
  • Idle — Pauses the current script for one frame, allowing other scripts and the game loop to continue.
warning

The timer script will be invoked recurrently even if the previous execution did not finish. If your timer script uses async events (like Actor Move To or Wait), multiple copies of the script may run in parallel. Keep timer scripts short and avoid async operations when possible.

Tips

  • Use timers for spawning enemies at intervals, blinking UI elements, or triggering periodic environmental effects.
  • If you need a one-shot delay (fire once, not repeatedly), attach the timer and remove it inside the timer script itself after it fires.
  • Remember that timers persist across the scene until removed. If you change scenes, remove any timers you no longer need.

See Also

  • Timer Event Glossary — Full reference for all timer events
  • Threads — Background scripts that run independently of scenes and actors
  • Tweens — Smooth value interpolation over time