O
O
OneTwoThreeFourFive2020-12-22 14:02:03
Game development
OneTwoThreeFourFive, 2020-12-22 14:02:03

How to optimize ping in multiplayer?

I roughly know how to make multiplayer, but I did not find an answer to the ping question. If one player has less ping, then that player will receive a response from the server faster than the one with more ping. This means that the game will be updated earlier for the first player than for the second.

The server sends the game state to all players, but all players receive responses from the server at different times due to ping.

How to optimize it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
antonwx, 2020-12-22
@antonwx

You can ignore this problem and try to solve it with the optimal location of servers for the target audience (this is how, for example, dota 2,
wow) , warframe)

D
dollar, 2020-12-22
@dollar

This is a very complex problem that cannot be solved in a nutshell once and for all. So the answer will depend on the features of the game. In general, no way . There is no universal recipe.
For example, if it is a turn-based game, then ping is not critical at all and it is possible to block the actions of all players until everyone receives an updated game state.
And if this is a shooter, then "blocking" the game is not an option, the player needs to be left with the ability to move his character and perform actions, and the server should retroactively count some actions or cancel too bold / abrupt actions (roll back to a more "honest" state ). You can also make all sorts of compromises, when different players display a slightly different state, but plus or minus is essentially the same (in meaning), and 1 step left or right does not count.
In "strategies" (that is, in games where there is a map and a lot of objects with physics or units with AI), in order not to send all the information about what is happening in the world, there is such an approach to send only player commands, and each one (on the client side) "simulates" the game, so it is the same for all players. With this approach, even small differences will lead to the problem of desynchronization of the game session with the need to send the save again.
In general, one way or another, these are some concessions, assumptions, rounding off, assumptions (predictions of the object's trajectory), restrictions, etc.
By the way, ping is still half the trouble. If all packets were guaranteed to arrive at least in a 300 ms window, it would be a fairy tale. Unfortunately, packets can still be lost altogether. And this also needs to be optimized somehow.so that the game does not lag and does not freeze. Again, the method depends on the game, and first-person games are the worst.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question