I’m working on a hobby project consisting of a multi-player web browser game.
It is my first and I have just stumbled into the latency issue.
I am trying to make user control as smooth as possible and latency is getting in the way.
I reckon that average latencies might be around 80-200ms and that for virtually-smooth control a command-action delay needs to be less than 100ms.
I have a few questions:
-
Would it be good practice to try and send user actions 100ms before required? e.g. User keeps the ‘->’ arrow key pressed, I submit the right arrow key action 100ms before action needs to be submitted to a server.
-
How do developees keep consistency/synchonise between what is happening on the online server and on the client?
-
Any tips or recommendations?
Thanks guys, help would be very much appreciated. 🙂
Question 1) Yes, but if you’re doing real time movement like that, I would consider rendering it locally (using collision detection and what not) and then validation on the server to ensure they didn’t cheat it (i.e. update the position on the server every second, and make sure they could have gone from A to B in one second, etc.)
Question 2) Every so often (quarter, half, full second) you send a packet with environment updates of what other players did and what npcs did and the like.
Question 3) Develop then profile. Make it the way you want it to logically. Then, if you find the playability is too laggy, work on optimizing the interface and networking layer. You might find it to be just fine!