PhotonView - how to make an object to be controlled globally

Options
I have a game object in the scene in unity. I would like any one online to be able to interact with it at the same time.

What happens now is when I click the object in one client, the PhotonView component will auto check "controlled locally". At this time I want another client to also be able to interface with this gameobject but its already being controlled locally at the first client already.

Comments

  • I think what I meant was how to make object ownership transfer from one client to another? maybe this question makes more sense? Any examples for sending me in the right direction would be great.
  • after further reading into the photon network documentation, one way is to use RPC to call master client to set RPC caller to be new master client. this way the game object becomes locally controlled, but there is a delay in updating the game object.

    If there are better ways to do this please advise. I need the game object to be controlled by all players in the game.
    for example, if one playing is pushing a cube in one direction another player is pushing in another direction the cube needs to react to both addforce... Please let me know if you might have some ideas on how this should be made.
  • Tobias
    Options
    Pushing something in a physically correct way is really tricky if many players do this over a network.
    Lag affects when messages arrive at individual clients and so each push is not being done at the exact same frame across all clients. If this happens, your objects might collide or not or with other things and each client shows something else.
    You usually need some controller for a game object to make sure it's clear who is right about the current situation.
    We don't think things will always look correct when using networked physics, so we don't want to support it, aside from "theory level".

    You could send the push RPCs as "AllViaServer". Then even the client that sends an RPC will execute it when the server sent it back. This gives *about* the same timing for the push on all clients. It at least gives you the same sequence for RPCs on all clients.

    The owner of the GO might send updates of the position which are not the same as locally simulated. You have to either skip some updates while things are pushy or you could send a "target/final position" for the GO, when it stopped moving again.
  • //movement coming from input for horizontal axis
    if(movement!=0)
    {

    PhotonView pv = PhotonView.Get (this); // 'this' is the GO cube
    pv.RPC("MoveCube", PhotonTargets.AllViaServer, movement); // MoveCube takes movment and moves GO
    }

    if change is made at master, GO in master and client screen moves smoothly.
    If change is made at other client, the GO at controlling client is jerky at the beginning, when the change does occour at all other including master client, the smoothness of the movement is also affected. Any advise on avoiding this jerky movement at the beginning ?
  • Tobias
    Options
    As said: One client is controlling and owning the GO. It will send updates where the GO is. If it sends position X, then all clients will move the GO there, overriding the "push" or "move" RPC someone sent.
    I can't help with code for this problem at the moment. I am not even fully sure if it can be solved completely smooth and without issues.
    Please try out things and try to figure out a way that works for your needs.