This project has moved and is read-only. For the latest updates, please go here.

Is Farseer deterministic? (re: networked games and Farseer)

Jan 14, 2009 at 1:30 AM
I'm thinking about creating a multiplayer/networked game and I'm wondering if Farseer can be used for this.

After doing a bunch of research on GameDev (and other sites) it seems like physics simulators, even with fixed timesteps, will never produce exactly the same results on two machines.  For example, if I have a stack of boxes and throw a ball at them at exactly the same velocity it will produce slightly different results on both machines (eg. the boxes will not land in exactly the same place).  Because of this it seems like you need to have a server or one simulation that corrects all the other simulations so that they stay synchronized.  (by sending packets every few milliseconds, etc)

Is this true or am I mistaken?

One idea that I have is a multiplayer sidescroller using physics but I need all simulations to be synchronized across several players.

Thanks for any help!
Jan 14, 2009 at 8:23 AM
This is true. You can never be sure that the same results will be calculated on different systems.
Most games use a master physics simulation on a server (as you said) that calculates the physics and send position and rotation to the clients.

Try searching on this forum and box2d's forum. Networked physics is a highly debated subject.
Jan 14, 2009 at 12:12 PM
Thank you so much for the quick reply (again).

What if I were moving objects by myself without a physics simulator?  For example, let's say I had a box moving (10.21, 11.57) per tick (10ms).  Just to complicate it we can also say that it's rotating 3.57 degrees per tick.  If I'm doing these same calculations (using floats of course), will it produce the same results on each machine or will it potentially be different?

I'm thinking about more simple games like Super Mario Brothers (without physics).  If we pretend it were networked then the two games would be moving the enemies around, etc.  Would it be able to do this independantly on each game or would the networking need to synchronize all positions?

Sorry for the questions.

Thanks a TON for all of your help!
Jan 15, 2009 at 2:34 AM
Yeah, but for this you might just want to send the position and rotation, and have it update on only one machine.  I'm assuming your using XNA checkout some of the networking samples like Network Architecture: Client/Server.
Jan 20, 2009 at 1:52 PM
Edited Jan 20, 2009 at 1:53 PM
Using the physics engine with an authorative server would be much simpler than trying to get the clients to synchronise or do their own calculations. That way, the client just becomes a dumb-terminal display which just draws some pictures at the position that the server tells it to.

A farseer sample to illustrate sounds like an interesting project...

Jan 24, 2009 at 1:15 AM

Depending on your needs, anything from a simple authoritative server, to the methods detailed with the above document may be the best for your solution. A good read at any rate.