2
\$\begingroup\$

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?

\$\endgroup\$
2
  • \$\begingroup\$ 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.) \$\endgroup\$
    – skyuzo
    Commented Oct 17, 2011 at 14:01
  • \$\begingroup\$ I kind of tried that and it didnt work properly. I have to user linear interpolation, right? \$\endgroup\$
    – gmemario
    Commented Oct 17, 2011 at 14:05

1 Answer 1

4
\$\begingroup\$

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.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .