Preventing visual & other problems with high / low fps

The proper solution is to base your animations around time that has actually passed.

With the introduction of the Maximum Framerate setting, this is even more important:

Luckily, they have generously provided examples of what and what not to do:

It looks like your code is currently doing the first thing, where you’re waiting for a fixed amount of time to pass and then updating the position based on that fixed amount of time.
Instead of:

while true do
  swait()
  newValue += 1/60
end

You should do:

NUMS_PER_SECOND = 60
while true do
  timeElapsedSecs = time.wait()
  newValue += timeElapsedSecs * NUMS_PER_SECOND
end
1 Like