Conquering Latency

In multi-user games latency is probably one of the biggest problems a developer can face.

To offset this, a combination of dead reckoning and cubic splines is generally used.

This flex program demonstrates the use of cubic splines in predicting the movement path of another player with a natural curve. [double click to create a new point, select a point to change it's rotation and render the path -- the 'pull' variable alters the strength of the curve] –sorry, it is a bit buggy.

Dead Reckoning:  is the process of estimating one’s current position based upon a previously determined position, or fix, and advancing that position based upon known or estimated speeds over elapsed time, and course.” (Wikipedia)

This applies to multi user games as a method of predicting (accurately?) where another player actually is.

The diagram shows the basics.  In figure 1  ‘A’ represents the last known position of the player.  ‘B’ represents the new position of the player from a server update.  When we get an update from the server we are sent the positional, rotational and velocity values of ‘B’, unfortunately, this is where ‘B’ was a certain number of milliseconds ago due to latency.  If we were to use this position, the viewer would be seeing a world that took place in the past.  This is where dead reckoning comes in.

We know the angle of B and we know the current velocity, so by simply interpolating the vector over the time lapsed we can arrive at ‘C’.  So our player over a the designated period of lapsed time would simply walk the path from ‘A’ to ‘C’ in figure 2.  This however is not very natural, so we redefine our path using cubic splines to arrive at figure 3.

This of course is not always accurate and that’s where correction algorithms come in.  An example of this is ‘rubber-banding’ in a multi-user game, when a player seems to snap to a new position.  That of course is not the ideal.

There is a lot of pseudo code available online that can be used to create the spline path.  If anyone would like my code, just let me know.