Push Rigidbody Around

Ironically I've got rigidbody character controllers working properly across the network, but I'm struggling to get something much more basic working: allowing rigidbody character controllers to push a rigidbody object (cube) around correctly.

The object I'm trying to push, a box, obviously has a rigidbody component and collider, more importantly it also has a PhotonView and a NetworkRigidbody component (which is from the stickied topic) enabled and the PV is watching the NetworkRigidbody component. Here's the oddness I'm encountering.

If the Server/Host pushes the object, the interaction is as expected, the box is moved and it updates to both the server and the client properly, looks smooth, etc. Great.

If the Client tries to the push object, he struggles, he can't move it hardly at all (I think because it's fighting to determine the position), and to the extent he can move the object at all, it's very jerky on both the client and the server.

To dig into what was going on, I ran as both server and client within unity so I could see the state of the objects and players in question. Here's what the box looks like when you're hosting:
Capture1.JPG

Here's what the box looks like when you're the client:
Capture2.JPG

NetworkRigidbody is enabled on both, the Scene is the Owner, seems right so far. The difference is in Controlled locally is both enabled and is set to master on the Host. On the client, this is disabled. Is this the problem, I admit I'm at a loss to figure out how this gets set. Any help or guidance?

Comments

  • Out of frustration, I went back to an old project I did with traditional Unity networking, I even copied the exact script where this works fine in traditional Unity networking over to Photon, an exact copy line by line, and it still doesn't work.

    The only thing I can tell that is different about how Photon treats this is the above screen shots, where traditional Unity networking labels the owner as a Scene, but does not seem to have the notion of "locally controlled" where Photon does.

    Again, all I'm trying to do is make a rigidbody (just a regular object, not a player controller) sync position/rotation properly over the network. This works from the Server/Host perspective, but utterly fails from a Client perspective. Other than locally controlled, I'm doing this exactly as I've successfully done it with traditional Unity networking, to the extent that I even ported over the exact script used, and it still doesn't work :/

    Any ideas, I'm in hang banging frustration mode :/ I'll even link webplayers of a working example with traditional Unity networking vs a webplayer of this not working with Photon if it helps illustrate the point (will also include the scripts for syncing rigidbodies over either version if that helps as well). Heeeellllp!
  • The problem will be that in PUN everything is owned by someone and only the owner of that GameObject can move / update it. So anyone who's running against a rigidbody to move it, will have a hard time moving it because it's owner keeps sending the positions it assumes being correct.
    I didn't know Unity can handle this case correctly. I guess they have an easier time because the host actually runs the physics and can immediately react when someone pushes the crate around.
    In PUN, some player "owns" the scene objects and there is more lag before that player knows someone else ran into "his" box. That will be a problem. But obviously, Unity handles the movement updates of remote players differently, so the physics can move the crate.

    I am unsure if we can solve this easily, I'm sorry to say.
    I will check with Mike if he has some great idea...
  • Thanks for the reply, I came to this realization as I did additional testing. Unity networking does handle this, and quite well using the NetworkRigidbody script, it would be really, really awesome if you guys found a way to bring this up to parity of Unity networking. Since I'm on a deadline I'll probably have to switch back over the Unity networking, since the game uses rigidbodies a lot, but overall I prefer Photon so I'd love if it supported rigidbodies over the network!
  • Tobias said:

    The problem will be that in PUN everything is owned by someone and only the owner of that GameObject can move / update it. So anyone who's running against a rigidbody to move it, will have a hard time moving it because it's owner keeps sending the positions it assumes being correct.

    I didn't know Unity can handle this case correctly. I guess they have an easier time because the host actually runs the physics and can immediately react when someone pushes the crate around.

    In PUN, some player "owns" the scene objects and there is more lag before that player knows someone else ran into "his" box. That will be a problem. But obviously, Unity handles the movement updates of remote players differently, so the physics can move the crate.



    I am unsure if we can solve this easily, I'm sorry to say.

    I will check with Mike if he has some great idea...

    I am having the same problem, did you guys find a solution? http://forum.photonengine.com/discussion/11410/please-help-sync-position-of-dynamics-scene-objects-is-driving-me-insane#latest
  • You have to let the MasterClient do all the physics.
    All the other clients need to disable the collisions.

    That should work really well.
  • Did anyone ever find a solution? I tried switching owner of the object with the rigidbody to the player that's the closest but when the ownership transfers there is slight lag but definitely noticeable and unattractive.