I am implementing client-side prediction and an authoritative server multiplayer architecture. I am following along with the series of articles from http://www.gabrielgambetta.com/entity-interpolation.html
I am at a point of confusion and have a few questions.
Within my client game loop I have a sequence of actions that update the local state.
applyLocalUpdates(state, loopTime)
reconcileLastRemoteUpdate(state, loopTime)
applyLocalUpdates
This updates all the entities positions based on their local physics and game logic simulation.
reconcileLastRemoteUpdate
I am in the process of implementing this and is the point of confusion. My initial naive attempt takes the last received server state and sets each local entities position to that last remote one.
This produces a choppy update effect. When each server update comes in the entities jump to match that last server position.
This is where I am trying to add interpolation...
I have interpolation methods like vec3.lerp(a,b,t)
and quat.lerp(a,b,t)
which I use to update the position vector and rotation quaternion.
My unknown points are:
Which values do I pass for
a
andb
in the interpolation?Is this the most recent local state and the last server state?
What value do I pass in for
t
in the interpolation?This I'm highly confused. Is this the difference of elapsed time between the last 2 server states?
Is it the difference of elapsed time between the last local update and the last server update?
Additionally, should I swap the order of execution between applyLocalUpdates
and reconcileLastRemoteUpdate
?