Jump to content
  • Advertisement
Sign in to follow this  
rumblesushi

Logic behind multiplayer physics

This topic is 2582 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm possibly going to add multiplayer to my first game, and I'd like to know the general theory behind it.

Obviously even in local multiplayer, you have ONE physics engine handling collisions between players, no different to player vs CPU collisions.

But what about online multiplayer? There you have 2 physics engine running simultaneously, how exactly is the collision handled?

One idea would be to share the computations between them, but surely that's actually a bad idea, as it means more network traffic when colliding.

So possibly the cleanest most efficient solution would be to determine which user's machine is performing better, whichever has the lowest time step between frames, and calculate the collisions only on that one machine, and exchange positions etc as per normal. Obviously this wouldn't apply to consoles, as the users would be on identical machines, but on PC's the logic seems OK.

How is it generally handled?

Cheers,
RumbleSushi

Share this post


Link to post
Share on other sites
Advertisement
Most games have a client/server logic meaning one people host the game, and another (or multiple) peoples join the server. From what I know, the server have the real objects physic positions and force them to all clients once in a while (avoid hacking), but the clients can use prediction on their hand using their physic engine to interpolate positions smoothly between server refresh (only visually). Of course it's probably much more complex and handled completely differently on multiple commercial game engines.

Share this post


Link to post
Share on other sites
You could for example make the server calculate physics for the objects and the players, and have the client calculate physics for the player and nearby objects (to make it look accurate)

If there is an error between the client side and server side objects, the server side data is used to fix their position and velocity, but for characters, the client side information should be used (if the error is small, and it should also be checked to make sure that you cant cheat by always telling the server that it needs to move the player forward a bit every update...)


You dont even need to do much server->client physics updates if the simulations dont have much errors.

You could lets say only update parts that the player has touched recently with a higher rate because the character is at different position on the client and server, and thus causing errors to the simulation...


Though if the client machine is laggy and cant proparly compute the nearby parts to make the physics look smooth you propably have to update more often :P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!