Are timers not Independent of fps? (screenshots inside)

This is exactly the wrong way to do it, because if your frames take longer than 50 ms to render, you will get fewer than 20 triggers in a second.

The way to do it is:

MyActorClass

  • TimeAccumulator: float
    Tick:
  • TimeAccumulator += DeltaTime
  • while (TimeAccumulator > 0):
    • RunOnce()
    • TimeAccumulator -= TimePerOneRun

If you want to run 200 times per second, TimePerOneRun is 1.0/200 or 0.005 for example.

1 Like