Skip to main content
GameDev.net gamedev.net
🔒 Locked

Networked physics

Started by bitshit Nov 18, 2009 at 12:10 PM 4 replies 4.3k views
Original Post
bitshit
bitshit
Hi all, There don't seem to be a lot of games that have rich physical interactions during online play... However, Garry's mod and Little big planet seem to do ok. Unfortunatly there's absolutely no information to be found on how they tackled it, the only source seems to be Gaffer... Garry's mod obviously runs on the source engine, but the source engine uses delayed synchronization to my knowledge. It seems like this would only increase latency problems during physics interactions? I thought this was the reason HL2 didnt employ full physics when playing a multiplayer game. Also Little big planet is heavily physics based, all interactions have their effect on the objects and multiple players can interact with the same physical object at the same time. Does anyone know how they do it? Thanks in advance! Martijn
frob
frob
Quote:
Original post by bitshit
Does anyone know how they do it?
I doubt you will get an answer from the people who actually know the implementation details.

While networked physics systems can be high bandwidth, there are many ways to make it reasonable.

Some of what you said is not quite true. All major objects interact with each other, but not all objects interact equally. There are major objects that always interact, and minor objects that interact with each other but don't actually affect the major objects.

You can learn a lot about the games by putting two consoles side by side. Most online games have a lot of wiggle-room about how much in sync they need to be at every step.

I'm guessing they have a combination of things. A deterministic physics system where the RNG is kept in order and in sync; Limitations on what the 'important' physics items are and the unimportant objects which react to them but not with them; low-resolution interactions with the characters so tiny movements don't cause a cascade of network traffic; physics blending to correct for latency and physics discrepancies when both players work together; and many other things as well.

It is a non-trivial task, but certainly possible with a bit of careful engineering work.
hplus0603
hplus0603
Quote:
I doubt you will get an answer from the people who actually know the implementation details


Why? It's not deep secret sauce; it's the implementation and the hard, sweaty work of actually making it work that's hard.

One thing that helps is that there's usually only one player interacting with a specific piece of the environment at a time. Whenever players interacts with players, or worse, two players want to interact with something in the environment, you'll have to crack open a can of fog juice, apply some sleight of hand, and mis-direct what's going on until you can patch up the latency problems post-facto.
enum Bool { True, False, FileNotFound };
bitshit
bitshit
As for implementation details;

I know the developers of LBP spoken on the GDC past years, I'm not sure if they discussed their networked physics implementation, but I thought maybe someone heard something...

As for the source engine, they've got the multiplayer techniques described on their wiki, but I don't see how that plays out so well for Garry's Mod. As each player is simulated in the past, artificial lag is added in return for consistency. This works out very well when you have some static players running around, but would only make physics interactions worse, because interaction between two players is even more delayed?
hplus0603
hplus0603
The Source engine game I've played the most is CS:S. There, if two players interact directly (running side-by-side in a tunnel, say), you'll be corrected by the server, which has authority. In this case, you will continually snap back, because you and the other guys will continually be corrected backward, and the only way to get up to full run speed again is to temporarily stop (hoping that the other guy doesn't) so you don't collide on the server.
enum Bool { True, False, FileNotFound };
Gaffer
Gaffer
Hey all, I've released the source code for my networked physics demo that I show at GDC, MIGS'09 etc

It's called "Fiedler's Cubes" and it demonstrates how to use an authority scheme to hide latency by taking authority over objects you interact with, as well as how to use distributed algorithms to keep a world of one million physically simulated objects consistent, even when players can late join - all without requiring a dedicated server.

This is not of course always the right way to do things, this demo is designed around a COOP game with networked physics and high simulation cost per-player, with the goal of avoiding paying for a dedicated server - but if you are interested in networked physics you will find this demo and source interesting :). It's BSD licence + non-commercial creative commons licence, so take a look at the source code feel free to steal all my ideas but please do not incorporate the source directly into commercial projects.

Source + MacOSX Snow Leopard 64bit binary is here:

Fiedler's Cubes Source + MacOSX Binary

There is also an alpha-Win32 port here, but I haven't had a chance to fully test that one, no PC at home... buyer beware :)

Fiedler's Cubes Win32 Binary (Alpha)

Feel free to ask any questions about networked physics in this thread and I'm happy to help

cheers,

Glenn Fiedler
www.gafferongames.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.