I am working on a real-time multiplayer soccer game.

Currently, on my game, I created an architecture like that:

  • Every client has a copy of the game state, also the server has it too.
  • Clients send their input vector (joystick data) to the server. (Local player uses the current input and moves).
  • Client waits for other players' input, once that data arrives I set rigidbody speed and direction. Then, it goes smoothly.

Things I use:

  • UDP (has lower ping)
  • Tick rate: 32 (increasing tick rate fixes this issue most of the time but not everyone's connection is strong and sending many packets in a second causes a ping issue)

Problem is:

Sometimes, the server and clients get de-sync and this causes every client sees another copy of the current game.

What I've tried:

  • Tried to increase the tick rate, but this only caused a connection with higher ping + packet loss.
  • Lerp between two states. This caused players seem like moving at different speeds
  • Lerp + Jitter. This caused players always see the game in a past state.
  • If client and server positions are different than a delta-x, use the server's position (normally this can fix the issue but sometimes server and client get de-sync every 4 tick and transporting object in 4 tick cause a very laggy/not smooth visual)

What is the best method to fix or handle this de-sync? And why it is happening?

Is it typical it happens in almost every 4-5 tick? (~9 times in a second)

  • \$\begingroup\$ Hello, Sounds like what you need is : Dead Reckoning, is it helpful? \$\endgroup\$
    – Mangata
    Apr 24, 2022 at 10:09
  • \$\begingroup\$ @Mangata Dead reckoning would work fine for simple moving objects but isn't ideal for player objects that may instantly turn around at any time. \$\endgroup\$
    – liggiorgio
    Apr 24, 2022 at 10:30
  • \$\begingroup\$ Can you tell us more about the game engine and netcode that you're using? In theory, if you have an authoritative server, you can always base yourself on the authority to sync the players back into their right state. You can have some latitude given to the player's client so that it doesn't always rubberband. However, once the gap between the player's client and the server is too big, you need to resync it authoritatively. If you're looking for a way to reduce latency as much as possible, you could check out Edgegap. They offer a low-latency cloud hosting solution for game servers. \$\endgroup\$
    – MariaA
    Apr 25, 2022 at 15:33
  • \$\begingroup\$ I have an old answer here explaining a technique called "Projective Velocity Blending", used for vehicle replication in Watch Dogs 2, which might be relevant to your needs. The GDC talk that I link in that answer may have other useful advice, especially if you're dealing with high-speed movement. \$\endgroup\$
    – DMGregory
    Apr 25, 2022 at 15:49


You must log in to answer this question.