[UE Notes] Delay and delay compensation

Lag is delay, which is a phenomenon that often occurs in multiplayer games. Lag compensation is delay compensation, which is a technology that reduces the impact of delay on games.

Ping

multiple meanings

  • An instruction (to verify that an ip address exists or that a host is running)
  • Describes how long the server takes to respond to client input

In multiplayer games where reaction time is important, the lower the ping the better

ping Latency (delay) and Lag (lag)

The ultimate solution to stuttering is having a good internet connection after all

Ping in the game has the following characteristics

  • Ping of player as host is 0
  • Infinitely fast internet connections don't exist in the real world
  • Can't assume everyone will have the best internet connection
  • This situation can be alleviated by setting up servers in different regions of the world (the closer to the server means the smaller the physical distance for the data to and from the server to be transmitted, and the lower the Ping)
  • Some non-real-time games are largely unaffected by ping, such as chess.
  • Fast-paced multiplayer shooting games need to pay attention to ping, high ping may lead to inability to play

delay compensation

Based on the premise that all clients will have more or less delay, lag compensation (lag compensation) is a technology to deal with delay. With enough lag compensation, clients will feel that their games perform better

And with enough delay compensation, it can even give people the illusion that the game has no delay at all

Delay compensation is also on the premise that the delay is not high. If the delay is too high, delay compensation is useless

In shooting games, players tend to notice a difference when the ping is higher than 50ms, but 50ms pings are very common, so delay compensation technology is used to deal with this

client prediction

Can be extended reading:

Client-Side Prediction allows the client to move first, informing the server that you are moving. Then do the real move on the server side, and copy the behavior back to the client

When the server's authoritative version is replicated back to yours, your role must be reset to this authoritative position, which results injitter

For example, the client may have moved forward 3m, but the server has only moved 2m, then you have to flash back 1m.

Proper server predictions will take this into account, know how many move requests are sent to the server, and only correct if the server and client are out of sync

Handle unimportant stuff locally

When it comes to other things that don't affect the important gameplay, there can be some things that are done locally on the client side without having to go to the server.

For example, in the matter of shooting. The server should naturally control whether the player's projectile hits someone else. But things like muzzle flashes or shooting animations can be handled natively. Different games handle this slightly differently:

  • Fires, but computer doesn't spawn projectiles (waiting for server to replicate back)
  • Fires, instantly spawns proxy projectiles but hits enemies without damage (server has its own authoritative projectiles and damage detection)
  • Fire, the client generates proxy projectiles, the server generates authoritative projectiles, and when the server copies over, the authoritative version will replace the proxy version

It all depends on the design of the game itself and the decisions made by the developer team. Each technology has its own advantages and disadvantages, but there are always compromises.

insert image description here

For details, see: [UE Notes] Local shooting effects in multiplayer games

interpolation

When the client synchronizes the location of the server, if the location gap is too obvious, there will be an operation similar to "flashback". This jitter will degrade the gaming experience. So the current position can be interpolated to the actual position, so that the transition is smooth. The disadvantage is that it takes time for the interpolation to slowly move to the correct position, and after this period of interpolation, this position has expired, so it is a delay in itself.

Extrapolation

If you know which direction your opponent is running, you can assume they will continue running in the same way. This method is not necessarily suitable for fast-paced shooters, and may lead to more serious inaccuracies than the case without extrapolation.

Character Movement Components for Unreal Engine

Unreal Engine's character movement component effectively employs several of the above approaches. If your ping is very high, you can still move your character, and the character movement component will use your speed to extrapolate your position on other machines to allow your character to move more smoothly on their machines.

If corrections are needed, the character movement component will use interpolation to smooth the corrections.

If the server and client positions are too difficult to synchronize, the character movement component will teleport you back to the correct position, this is Rubber-Banding

Because the character movement component does a good job of compensating for latency, we generally see other players moving smoothly in our game. And even with the lag, we still have a smooth experience, at least until the ping gets too high.

server rewind method

The server keeps track of the player's location and stores this information in some kind of movement history. When the client attacks, it will send the details of the attack to the server, including the time of the attack, and then the server will check your attack time, rewind the time and reposition the player to their previous position at this point in time, and check your attack information based on the client's attack information. Bullet or ray tracing actual hits between server authority roles. From this, a judgment on whether to hit/kill is made and feedback is given. The server then puts all the characters back in their correct positions and continues the game.

This caused a player to be eliminated even after running behind cover, since it was possible to rewind and get hit before running to cover. This is friendly for high ping players, but may have a bad experience for others.

You can choose not to use rewind for certain players when their ping is too high.

In short, in order to deal with the game experience of players between different ping values, there is always a trade-off. If you're convinced that a game's responsiveness is important, then do what we can to compensate for lag.

Guess you like

Origin blog.csdn.net/qq_39377889/article/details/128481168