networking and physics

So, i have a nice avatar chat app that uses electro-server 5 for its real time networking. Since the app itself is simple, physics can easily be ignored. However, now I want to add more interaction between the players, so we can play sports and other activities. To do this, I would like to use unity’s physics engine (mostly on the ball or other objects), but seeing as the server itself isn’t made with unity, how can I use the physics system without the objects getting out of sync? Is this even possible?

thanx

Make the game in unity and then use the servers to host. Just take the general idea of the game and make it in unity.

HUH???

maybe i should clarify my first sentence with:
“So, i have a nice avatar chat app thats built with unity that uses electro-server 5 for its real time networking.”

even with that clarification, your answer doesn’t really address the problem.

I don’t know anything about electro-server 5 but if it doesn’t have native Unity support I’m not sure what you want to do is possible.
We are currently implementing an authoritative physics based server using uLink as our networking solution and it fully supports it.

interesting. I’ll check out ulink and I’ll see if i can get some general ideas on what to do.

[edit] ah, it seems that a unity exe will be the server, so i cant really use any info from there.

anyway, I think i have some ideas on how to accomplish what i want, but it will be limited. For my purposes, it should be enough tho. We shall see…

What you want isn’t easy by any stretch.

Most rigidbody simulations, including physX, are not deterministic. If you run the same simulation twice with identical starting conditions, you’ll end up with deviation due to floating point precision. When you add in the fact that your game might also be running on different hardware and varying floating point architectures it adds to the pain.

If one player thinks at time X the collision was head on, another player things it was a side impact while the server has a totally different idea… how do you resolve that?

What this means is you can’t just count on usual techniques of prediction and interpolation to hide small discrepancies. The client and server simulations invariably end up way out of synch in short order. You can see this happening in the above video.

Google is your friend. There are dozens of white papers written on the subject and the voodoo spells necessary to trick people into believing they’re playing in a coherent physics simulation. Principle of least astonishment, switching temporary ownership to a client, etc.

Hmm… I use prediction and interpolation without a problem. I don’t currently have a solution when your lag is enough you fall into the extrapolation regime, but the interpolation regime with < 100ms lag seems to be fine. I’ve done a lot of testing at 70-80ms.

Discussion and code here: http://forum.unity3d.com/threads/125084-objects-owned-by-other-players-twitch-when-moving-in-the-same-direction-as-the-player