How to use delta time?

Ooh I thought you were looking for smooth animation, the topic that I answered about. :blush: If you just want something to happen once every 5 seconds you could use setInterval like below.

There’s also other options, e.g. you could use engine.getDeltaTime() to get the unclamped, actual time since the last frame and use a counter… Or you could use Date.now() to get the current time in milliseconds and calculate your own delta from the last event that way. Also there’s external libraries on GitHub for timers as well. These days I mostly just use setInterval thou with long timeouts for things that aren’t as important, and then just use getAnimationRatio for everything that needs to update each frame… :slight_smile:

1 Like