Monday, December 25, 2017

networking - Client-side prediction and interpolation


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?





No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...