Stop one long lag spike from throwing everything across the screen
When the window loses focus or the computer stalls for a moment, the next frame reports a huge time step and characters teleport, tweens jump to the end and physics explodes. Here is how to tell a one-off spike from a genuinely slow computer and treat each properly.
Why this works
A single long frame is an accident, but a slow computer is the new normal, and the two need different answers. Judging a frame against the recent past lets you throw away the accident and still keep the game running at true speed on a weak machine.
When not to use it
Don't use it where the true elapsed time matters, such as a race clock, an online match or music. There, a stall must count as real time. Filter only the motion, and let timers and sound follow the real clock.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 21 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Stop one long lag spike from throwing everything across the screen" (read_entry ignore-lag-spikes-in-frame-time) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP