Input prediction and server re-simultaion
- by Lope
I have read plenty of articles about multiplayer principles and I have basic client-server system set up. There is however one thing I am not clear on.
When player enters input, it is sent to the server and steps back in time to check if what should have happened at the time of that input and it resimulates the world again. So far everything's clear.
All articles took shooting as an example, because it is easy to explain and it is pretty straightforward, but I believe movement is more complicated. Imagine following situation:
2 players move towards each other.
A------<------B
Player A stops halfway towards the collision point, but there is lag spike so the command does not arrive on the server for a second or so. Current state of the world on the server (and on the other clients as well) at the time when input arrives is this:
[1]:
-------AB-------
The command arrives and we go back in time and re-simulate the world, the result is this:
[2]:
---AB-----------
Player A sees situation [2] which is correct, but the player is suddenly teleported from the position in [1] (center) to the position in [2].
Is this how this is supposed to work? Point of the client prediction is to give lagged player feeling that everything is smooth, not to ruin experience for other players.
Alternative is to discard timestamp on the player's input and handle it when it arrives on the server without going back in time. This, however, creates even more severe problems for lagged player (even if he is lagging just a bit)