Hi,
I read this article https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking, and I am struggling to understand how client synchronizes itself with the server when it performs prediction.
More precisely, the client performs prediction of player behavior according to current inputs without waiting for the server computation. But in this case, it means that the client is ahead on time compared to the server.
When the client receives a server state update, what does it do?
Does it updates its state without taking into account user inputs? As it was ahead of time, maybe the current state update does not contain the effect of the last user input.
Does it wait for an update that take into account the user input? But in this case, as there may always be new inputs, the server state is always delayed compared to the prediction.
--> position received is always obsolete.
Also, in the article, they explained that rendering is 100ms late compared to the simulation. Where is the user input prediction taken into account?
At the client simulation time (so with a 100ms lag due to rendering being late) or at the rendering time?
My understanding:
the client never synchronizes the state of entities for which it has predicted the behavior (I mean it does not just copy paste the server state).
It keeps history of its prediction, and when it received server updates, it checks that its past predictions were correct (not current one as it is already predicting new commands...)
If the past prediction were bad, it rewinds its state to the tick corresponding to the discrepency and recompute prediction with new commands.
So for the user's entities, client side is ahead of time compared to the server. For the other entities, client is late compared to the server.
Thanks in advance for any help, and sorry for my english i did my best.
Franc'