I’m currently implementing a dead reckoning / client-side prediction algorithm algorithm in Unity. I got the client-side prediction part working pretty well, but when it comes time to update the client states, I am getting screwed over by the fact that the physics engine cannot update rigid bodies instantaneously.
On the practical side, what I am seeing can be described as follows:
-
I received a response from the server that the correct state to be at for say timestep 0 is (0, 0, 0). I am at timestep 3, so I pre-form reconciliation to receive the corrected state (0, 0, 3), assuming that I move one unit in the z-axis every movement tick.
-
After computing this, I correct the client, and set rigidbody.position = 3.
-
The correction happens the tick afterwards, so rather than being at rigidbody.position = (0, 0, 4), I am at position (0, 0, 3), which means that I continue to have a 1 difference on the z-axis error compared to the server.
Has anyone in the past figured out a way to resolve this delayed physics updating issue? It’s been driving me crazy.