2
\$\begingroup\$

Although my game uses a peer-to-peer model, I've still taken the approach of assigning each player to be a partial authority. What I mean by this is that each player acts as the "server" for a number of objects, and all the other players are "clients" for those objects.

It also uses a fixed update interval and variable render interval. I'm considering a 50Hz update frequency, so the rendered time lags behind the current time by 20ms in order to guarantee two states to interpolate between.

When a client recieves authoritative state information from the server, it comes with the timestamp of when it was sent. Because all the players use a synchronized clock, the client can correctly place the state along its "update timeline", the state history of which is stored for up to 100ms back.

However, in order to hide latency, each client also predicts the behaviour of all objects in the vicinity, regardless of whether or not they are the authority.

The difficulty I'm having is figuring out how to correct errors on the client side and stay synchronized with the server state, when server information for a specific object will be coming far less often than updates happen. What is a good way to smoothly correct current information with information from the past after several prediction steps have been done on estimated information?

\$\endgroup\$
1
\$\begingroup\$

You don't need to correct the errors on the client right away. If you interpolate the current client info with the incoming server info, the client info will converge to the server info in the next few frames. Since you are expecting the server info arrival to be less granular than the client update, when some info arrive at the client it will have enough time to converge to the expected state. I think you will have to experiment a little bit with the interpolation parameters to find a good guess for the number of steps until convergence.

\$\endgroup\$
  • \$\begingroup\$ But what if the difference between server and client state was that for example on server player fell from the platform while on client the player did not. This is not something that minor interpolation will fix - what do you do then? \$\endgroup\$ – Mykybo Oct 2 '17 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.