1
\$\begingroup\$

We are building multiplayer game where there's no central server managing the game.

Each player is responsible for sending out its state to all connected players.

In addition, all clients run prediction between received packets, to keep all objects moving in between state packets.

We also smooth out the positiobs received from remote clients, for example in scenarios where the received oosition is small enough and should be moved smoothly from the current predicted position.

The issue I am trying to handle is how should the algorithm behave in case it hasn't finished smoothing out the position yet, and a new state is being received?

The smoothing algorithm currently operates for a given configured duration (e.g: 80 ms). Should a new incoming state cancel the ongoing smoothing? What is done in such cases?

One option is to never reset started smoothing, that is, run for the whole 80 ms, but update the target position in case new state is received.

Another option would be to reset (start the 80 ms count all over again. This time with the new start/end positions).

Both options have their issues. I am wondering whether there's a formal way to deal with this.

\$\endgroup\$
0

1 Answer 1

2
\$\begingroup\$

Client-side dead reckoning / extrapolation, prediction, and gradual reconvergence.

Once you receive the data you've been waiting on, you probably don't want to do full corrections at once, but rather start interpolating these into client-side position values (which are presently the consequence of one or more predictions, during which time the client was diverging from the server state) such that you begin reconverging toward the server-dictated simulation state, over the next several frames. At some point after that, you could simply match the state of the server exactly (complete refresh for client).

Gaffer describes the process in detail. Running your simulation a frame or two behind ("late") can also assist with this.

\$\endgroup\$
2
  • \$\begingroup\$ In my implementation there's no "server" \$\endgroup\$
    – spaceOwl
    Commented Dec 6, 2013 at 17:18
  • \$\begingroup\$ @spaceOwl These days, some client is typically going to be authorative. You may want to take a decision on who that will be (perhaps the player who started the game, or the one with the best connection speed). Alternatively, consider the Age of Empires approach : run clients in P2P lockstep with some prediction. IMO, not so good for real-time performance, but it can be made to work. \$\endgroup\$
    – Engineer
    Commented Dec 6, 2013 at 17:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .