I've started work on a basic grid based multilayer game.
The game is made to run at 15fps, so data is sent around every 66ms.
Right now what I've got working is clients joining, getting a player spawned, and a start on movement.
Everything works fine as long as your round trip for a packet is less then 66ms. after that movement gets jittery.
That was expected though, because of how I'm handling the movement.....
Here's basically how it works:
- Client 1 tries to move the player in a direction.
- Client 1 checks if it can move the player
- Client 1 sends the request to the server
- Client 1 moves its player.
- Server checks if the player can move.
- Server moves the player
- Server sends all clients the new position of the player
- Client 1 moves the player to the position the server sent back (if it has to).
A basic authoritative server, right?
If the client moves the player more than once before the server returns with first movements data,
the client will think its in the wrong place, thus the player jumps around between grid spaces. (jitter)
The solution would be to keep track of a player's movements and match them up with the proper packets (by ID-ing them I suppose)
but what if packets are dropped?
What if the packets return out of order?
oh and, I've read this article http://www.gabrielgambetta.com/fpm2.html.
which describes my situation pretty well....
I'm just really unsure of how its implemented.
Thank you for the reading/helping!