@sheep19: You probably want to number each game simulation tick. Make sure you use the same, fixed, tick rate on all nodes! The player would then enqueue commands "for the future" for the server. This would include both "spawn bullet" as well as "move" or whatnot. The server applies the appropriate input at the appropriate simulation tick (so at each physics update on the server, only one input from each client can be applied).
I don't quite understand this.
If understand correctly, the server will keep a counter _simulationTickCount which will increment on every physics update?
Clients will do this as well, and send the current tick count with every input packet. Then, the server applies that input at that tick rate, based on its count (_simulationTickCount).
But, due to latency, the server will always be ahead of the clients, right? So when the server receives an input with tick count 15 (from client A), it might actually be at _simulationTickCount 30. What does it do in that case? Furthermore, another client, B, which has more lag than client A sends his tick count 15 at 30 server tick rate... What should the server do?
============
I also have another issue.
Currently, when an input is received, the server sets the rigid body's velocity of the client to a certain value, updates the physics world and then resets it back to zero.
This causes the local client to always be ahead of the server... (and because of corrections, the player's model "jumps" to the corrected position).
But from what I read, what should happen is that the server should be ahead of the client. This make me think that what I'm doing above is wrong.
Should the server assume that when an input is received (e.g RIGHT arrow pressed) that it remains active until a packet containing RIGHT as not pressed is received?