Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm adding multiplayer to an iPhone game that we have in our company. It's a sort of 'table hockey' game, with a puck and two mallets.

It's a pretty fast game, so I need a smooth experience at both ends. What I'm doing right now is using Game Center, and setting up the iPhone that starts the game as the "server."

So, the client runs its physics the same as the server, but the server adjusts the speed of the puck on the client and adjust its position when they are going on the same direction. The problem that it has some glitches, when the physics simulations differs a bit between then and the server sends the command to correct and the client kind of jumps around.

Does anyone has a suggestion how should I can handle this? Or should I try a different way?

share|improve this question
    
You could send the clients the position and velocity at regular intervals and then use the velocity to have the client predict where the pucks are in between those intervals. (Unless you're already doing this.) –  skyuzo Oct 17 '11 at 14:01
    
I kind of tried that and it didnt work properly. I have to user linear interpolation, right? –  Gilson Oct 17 '11 at 14:05

1 Answer 1

The general technique is for the the server to maintain authority, and send the game state updates to the client as rapidly as needed. The client maintains a local copy of the game state which it simulates itself, predicting that most of the time the server will confirm the input it sends. When the server game state and client game state differ, you adjust towards the server state, usually interpolating to hide sudden transitions or rubber-banding effects.

It's not clear from your post what the underlying transmission medium is (TCP versus UDP). Because you have a fast-paced game, you probably want to use UDP and simply send the client state updates as fast as possible. This is what is usually done in other fast-paced games, like first-person shooters.

You can look up client-side prediction resources on Google.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.