I realise that this is one of those questions that gets asked multiple times a day, but after extensive research i wasn't able to answer one specific question (which i will get to.)
(And yes, i've also read the "Fix Your Timestep" article.)
So what i wanted to implement was a fixed update tickrate (like 60FPS) with the ability to unlock the rendering framerate to render the game as fast (and as smooth as possible.)
The "easiest" approach would be to use a variable timestep (delta time) but i don't want to do that. Mainly due to consistency of the game physics/behaviour across multiple playthroughs.
So from what i was able to gather, there are two ways in implementing a gameloop with a fixed tickrate and an unlocked (variable) framerate:
> Interpolation and Extrapolation.
Extrapolation is basically a "prediction" of the gamestate in the next frame (which wasn't calculated yet on the CPU side.) So you do something like position + velocity * interpolationvalue during rendering. This may work, the issue is that the extrapolation can have wrong results (objects passing through geometry for a short timespan) before the position is corrected. Also movement which is non-linear like rotation, acceleration, etc... would also have wrong results.
The other things is interpolation. I like the idea of the approach. We take the last frame and the current frame and interpolate between them while the next game update is being processed resulting in smooth motion and it allows us to render the game at a higher framerate.
Now the caveat here is latency. Because you interpolate between the last frame and the current frame, your game state is (visually) always 1 frame behind.
This essentially increases the latency/responsiveness of the game. (At 30 fps its 33.33ms, at 60 FPS its 16.66ms)
In my opinion this depends entirely on the gametype if this latency is acceptable or not. RPGs might get away with it, but fast paced games with emphasis on fast/reactive gameplay can suffer. And given that i'm working on a game which emphasizes fast/reaction based gameplay, this is an issue which i want to circumvent. (Currently i update at a fixed rate of 60 FPS.)
So my question is:
How do games with the requirement of consistent physics/behaviour implement their gameloop while retaining the ability to render at an unlocked framerate?
Competetive games come to my mind. But especially the Trackmania Series.
AFAIK Trackmania has consistent physics (Otherwise all those "press forward and let the car magically drive through the whole track" maps wouldn't be possible) . But it's also able to render at an unlocked framerate.
Here is a video where someone did a benchmark and was able to run the game at 200-400 FPS:
[media]https:
My question is: How is that possible? Trackmania is a fast paced racer which needs low-latency input (I can't imagine that they are sacrificing substantial latency for framerate independence). Are they using interpolation at all? How is their gameloop implemented?
The only solution i'm able to come up with with regards to interpolation is making the game update at a very high (fixed) rate (like 200 ticks per second.) in order to reduce the latency as much as possible.