In every multiplayer game, one of the most complex issues is to keel all the state of the player in sync with the server state. In order to make sure that all client are in sync, the easiest way is to allow the client send update to server in the fixed interval. Apparently, the update would contain user input that can also represent “no user input”. Once all the servers gather input from all users, it is able to be proceed with the next tick using those inputs.
There are several issues including two of which just mentioned before:
- Client will not respond until it has got the state update from the server which is can be considered as the horrible user experience.
- The responsiveness of the game depends on the most lagged players. do you want to play with a friend with DSL connection? Have fun!
- The connection itself can be really chatty. In this case, every client has to send some useless hearbeat data regularly so that the server can confirm that it has all of the information needed to step forward, which is not efficient.
You have to know that particular kind of games are immune to these issues, most Turn-based game actually use some variants of such model, as client are supposed to wait. As for slow-paced game, small amount of delay can be accepted as well. Farm Ville is one of the good examples. Another one is called Chess. It is where 2 players take their own turn, assuming each turn takes 10 secs.
- Every user is expected to wait for each other for 10 secs. They wait.
- Two players take turn alternatively. in this case, no one lagged okayer does not affect the other player.
- Every turn takes on average 5 secs in which one request every 5 secs is fine.
Some of you might have already find out the answer. Instead of waiting on a server update, the client is able to actually emulate the game by running game logic locally, including the one on the machine of the client.
The fact is that the client runs on it’s own update rate. On the other words, it is independent to the server update rate. Therefore, if that server is having hiccups, it does not affect client side frame rate. Whether you agree or not, it comes with some complexity:
- You have to handle more state and logic on the client side such as prediction buffer, state buffer, and prediction logic.
- You have to decide how to handle conflict between prediction and real state from server.
In conclusion, you have went through only 2 ways of approaching multiplayer game networking which are lockstep state update and client prediction. Do not forget that each comes with it’s own set of trade off. If you have any questions, it is better for you to ask for a help from the expert that know this kind of things.