2
\$\begingroup\$

I want to implement a strategy/artillery game, similar to Worms/Arcanists.

As game-development (and game-networking especially) is new to me, I was wondering whether this would be a good/performant way to do the movement-networking:

  1. Server has all client's positions.
  2. Moving-client to server:

    Message: [start-moving, moving-direction]

  3. Server now starts a simulation of the moving-client moving.

  4. Server to all clients, except originating one, every 100ms(?):

    Message: [set-client-position: client-id, new-position] ^ new-position calculated by the server's simulation

  5. Clients lerp the moving-client's position.

  6. Moving-client to server:

    Message: [stop-moving] ^ server's simulation ends

  7. Server to all clients, including originating one:

    Message: [set-client-position: client-id, final-position] ^ all clients have the same position for the moving-client in the end

\$\endgroup\$
  • 1
    \$\begingroup\$ Looks fine IMHO. Since it's Worms, it's not entirely critical that all clients have exactly the same position for a worm while the worm is moving, only once the worm has stopped moving. You might even be able to get away with sending step 4 to all clients. \$\endgroup\$ – Steve Smith Feb 9 '17 at 16:14
1
\$\begingroup\$

I would also have the client send its absolute position to the server as well. The server can still simulate the movement if you desire, however this is useful to prevent the two positions getting out of sync with each other due to subtle differences in the collisions at different locations.

What the server can do is trust where the client is telling it the worm is, unless it suddenly jumps too far, in which case, if the server disagrees with the clients position, it can send the expected client position back to the original client (as Steve suggested). This is why games often experience rubber banding.

I personally prefer trusting the clients position, as it leads to a higher degree of accuracy. You should still send the direction/velocity, for simulation purposes between frames.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.