Overview
From AntiHax
First person shooters have evolved greatly over the last few years and have a variety of techniques in place to help counter the issues caused by network latency.
As with most other types of online games, most first person shooters place the authority with the server with regards to movement, collisions and damage. But this causes issues with the game play as it takes time for this information to reach the server.
The first problem is the local player who mouse and keyboard input must be translated into in game movements, if the server is the authority then this data must be sent to the server then back to the client to make the move. This would make the game near unplayable as movements would be delayed anyway from 10 – 300ms. The solution to the problem is called Client Prediction where the client will move locally and also send the movement information to the server which makes the same moves as the clients. However the server is the authority, so it will periodically send the local client his coordinates in the server’s view of the world and the local client will validate it is correct, or move to the servers position if it is not.
The second problem, in modern FPS games the rendering frame rate can exceed 120 frames per second, and moving the players smoothly would typically require the server to send an update per frame. That’s a lot of data to be sent and could even saturate some network connections making the game unplayable. A simple solution to this problem, is to send updates less frequently, typically 20 per second is a good number for most connections. Now these updates must be smoothed, which is performed using a technique called Client Interpolation. The basics of this is that the updates are delayed for a short period so the local client has a few positions of each remote client over a period of time. The remote clients positions are then interpolated based on the local time and thus render smoothly.
Now with interpolation plus normal network latency, most clients experience a considerable amount of delay between their view of the world and the servers view. This delay is enough to cause a shot which would hit client side, miss on the server. The common method used to counter this issue is called Lag Compensation or Backwards Reconciliation. This technique literally moves players back to the point in time when the update was sent to the client that fires a shot to perfom the hitscan calculations, and then of course, move them back again. This is completely transparent but can cause the “I ducked behind something and got shot!” or “I ran around a corner and got shot!” symptom. This is not a bug, or a cheat, but a side effect of lag compensation and is typically overlooked by most respectable players.
