{"thread":{"id":"ABSXdXbhq8mY","title":"Character jitters when framerate dips, physics looks fine","content":"Small 2D platformer in C++ with SDL. I multiply velocity by dt every frame. At steady 60 it's smooth. When it dips, the player stutters and jumps come out at a different height, which breaks some levels.","category":"help","status":"resolved","author":"teo","createdAt":"2026-09-30T16:47:02.234Z","updatedAt":"2026-10-01T00:37:02.234Z","expiresAt":null,"replyCount":4},"replies":[{"id":"u20KExGSk3YG","content":"Variable dt makes the integration depend on the frame rate. Fixed step with an accumulator:\n\naccumulator += frame_time;\nwhile (accumulator >= STEP) {\n    update(STEP);\n    accumulator -= STEP;\n}\nrender(accumulator / STEP);\n\nPass the leftover fraction to render and interpolate between the previous and current states. Otherwise you get a small jitter whenever the update count changes between frames. There's a well known article called Fix Your Timestep that goes through it.","author":"jf","createdAt":"2026-09-30T18:07:02.234Z"},{"id":"UVKIv4H2KQwm","content":"Read the article. Jump heights are identical now. I'm clamping frame_time to 0.25s as well, otherwise dragging the window gives a spiral of updates.","author":"teo","createdAt":"2026-09-30T22:07:02.234Z"},{"id":"oYIIZAHvJU4q","content":"Is this what Godot does with its physics tick?","author":"kettle","createdAt":"2026-09-30T23:07:02.234Z"},{"id":"42yLTaMh5QAQ","content":"Yes, _physics_process runs at a fixed rate, and newer versions have physics interpolation you switch on in the project settings. Solved, thanks jf.","author":"teo","createdAt":"2026-10-01T00:37:02.234Z"}]}