How do online games achieve latency-free gameplay?



Many good online games allow for comfortable gameplay, with little

latency or ' latency ' when processing input from the controller. Datadog engineer Evan Jones explains how to achieve a comfortable gameplay despite the latency between the client and the server.

Networked games: Playing in the past or future (evanjones.ca)
https://www.evanjones.ca/network-game-simulation.html

Latency exists in local games as well as online games. For example, in a game that has a process of 'reading input from the controller to draw the world', there will be latency after the player presses a button and before the world frame is drawn. In many games, the maximum frame rate that is the frame processed per unit time is 60 fps, and at 60 fps, an average latency of 8 ms occurs. In addition, in the local game, the lower the frame rate, the more latency that occurs from the input of the player until the screen is updated. Many games are drawn at frame rates lower than 60fps, which adds to the delay.



Online games have more latency than local games due to communication issues between the client and server, as well as frame rate issues. Jones created a simple demo to understand latency protection in online games. The demo created by Mr. Jones reproduces the state of the client and server in the online game and can confirm the latency by simulation, and the source code is published on GitHub.

GitHub-evanj/netgamesim: Network game simulation: not a game, but simulates how they work

https://github.com/evanj/netgamesim

What is implemented in Mr. Jones' demo is a network model of a simple online game that 'the client sends a command to the server, and the server sends the drawing data of the screen to the client based on the data obtained from the client' .. For example, if you send an action to move the character forward to the server, the client needs to make one round trip between the client and the server before drawing the actual character movement on the game screen.

For example, in the figure below, 't' is the time, 'x' is the distance, 'Client' in the upper row is the client side that sends the player's operation to the server, and 'Server' in the lower row is the online server side.



Both the client and the server start the game when t is 0. Since the player has pressed the 'forward' command, the client sends the server the data 'move'. The time it takes for the data to reach the server is 1, and when t is 1, the server receives the data from the client.



When t is 2, the server sends the drawing data (pos=1) advanced by 1 to the client.



After t becomes 3, the client will receive the data from the server, and it will be reflected on the game screen in sequence. This means that the client has not been updated between t 0 and 2 and has a latency of 2 units.



According to Mr. Jones, instead of receiving commands from players and returning drawing results as they are in multiple online games, the drawing results that predict the next action the player will take from the action taken by the client It is said that the side is displaying on the screen. For example, the design that hides the latency in the action of 'advancing the character' is as follows.



When the client sends an action to move the character forward to the server at the start of the game, when t is 1, the client predicts the server's response and draws a step forward on the screen.



When t is 2, the client predicts the action one step further and draws it on the screen.



The client receives the original online drawing data from the server when t is 3. Check if the data received from the server matches the client simulation. If they do not match, the client will have to redraw.



Early online games such as Doom and Quake , which appeared in the 1990s, were released when the Internet became commonplace in the home. Doom and Quake do not implement the process of predicting the movement of the player and drawing the screen, and received the command from the player and returned the drawing result as it is, Mr. Jones has a latency of about 50 ms. I'm guessing. Jones described an online game that predicts the behavior of the player to hide the latency as a game that can play the future.

in Software,   Game, Posted by darkhorse_log