Saturday, July 25, 2015

networking - Implementing network smoothing


We are making a multipler first person shooter. The client sends it's position to the server at a fixed rate (currently at 10Hz). The server sends a single message contatining all player's positions to all players at the same rate (10Hz).


As expected, the movement is pretty choppy since the 60fps game is only recieving updates 10 times a second. What is the best way to smooth this movement? The most obvious way would be to interpolate between the last two packets, so that the interpolation finishes as we recieve a new packet. But this adds an instant 100ms delay for all players.


The other way would be to use the velocity and acceleration inferred from the last few packets to predict where the player is before the next packet arrives, however if the prediction is wrong, the player would tend to jump as soon as a new packet is recieved.


Does anyone know how AAA titles solve this problem?



Answer



They do exactly what you've just said - either one of those two approaches, or some compromise between them. (eg. accept a small delay and interpolate where possible, and extrapolate when the ping exceeds that delay.) Instead of jumping (also known as 'snapping') back to a corrected position, you typically do some sort of interpolation between the wrong prediction and the corrected value, smoothing it out, if possible. You also handle the corrections in the past to reduce the amount of correction you need to apply.



This is a frequently asked question and there are several canonical links which you will probably find elsewhere on gamedev.stackexchange.com if you search, and they include the following:


What every programmer needs to know about game networking (this summarises stuff in the next two links)


Source Multiplayer Networking


Unreal Networking Architecture


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...