Reputation: 1210
I have a table hockey game for iphone and now i'm doing the multiplayer part of it. I decided that the iphone that starts the match is the server.
The physics are running on the server and on the client, so the client look keeps smooth e not 'jumpy', since its a really fast game.
The server sends constant messages to the client, so the client can adjust its position and velocity. The problem is that sometimes the client jumps back on position because of the delay.
I've done clock sync on the client and the server, so i can compensate the X and Y position, through the clock difference and the velocity the server sended. The problem is that its looks kind of jumpy. How can i synchronize this thing? I've been trying all sort of stuff but it doesn't seen to work.
Thank you.
Upvotes: 0
Views: 1206
Reputation: 385890
You're describing a well-known problem with client/server game state synchronization. Quoting this article:
The most complicated part of client side prediction is handling the correction from the server. This is difficult, because the corrections from the server arrive in the past due to client/server communication latency. We need to apply this correction in the past, then calculate the resulting corrected position at present time on the client.
Have a look at that article, particularly the section titled "Client side prediction".
Upvotes: 2