Trying to set the camera and children/scripts on the camera to isMine but doesn't work. Please help!

I've recently added a new look around script(from the standard assets).
Now instead of the camerascript being on my player (and being started in ThirdPersonNetwork script) (which is on my player) I have the freelookcamerascript and the protectcamerafromwall script on my camera script.

From the quick tutorial on PUN Basics tutorial I noticed I could be doing the third option (they chose option 2) as demonstrated here:

Script is below with a link from codepad. At the moment I'm just enabling and disabling the camera but as soon as someone joins the camera gets disabled for them as they are not the owner.

Please help, I've been breaking my head over this for hours!

Camera hierarchy

Camera scripts:

Script FreeLook:

So I suppose my main question would be: How do I achieve this?
The follow up would be: How can I, in the future, decide which object should belong to me? (also, how does the photon view work, which transform should I put in there? Or none?).


  • UPDATE: I'm not sure how I did it but I found this on the forums and implemented it in the thirdPersonNetwork script:

    Could someone tell me if this is the correct way?
    The photonviewer on my freelookCamera GameObject still says scene is the owner and it's id 2.
    Could someone explain what's going on so I can grasp this better?
  • HI @Icezman,

    I'm not sure, but it seems the problem is that you want to make the main camera a networked object, which is not working in your case. I'm also still not sure about the setup you have, so I have some questions. Do you instantiate a FreeLookCameraRig for each player? If so, does the prefab already have a camera object as a child or is the 'main camera' what I assume it is? Do you have to make this object synchronized at all since it is a FreeLookCamera? If not, you can skip the entire synchronization step.

    An approach to make it work: When a clients joins a room, he network instantiates a FreeLookCameraRig prefab without a camera object, if this object has to be synchronized. In this case it must have an attached PhotonView component and either the PhotonTransformView component or a custom OnPhotonSerializeView solution as well. You now have two options. The first is to make the main camera a child of the player's object, but only on the local client. In this case it would be updated with the movement of the object itself, but wouldn't be synchronized with other players - which is good. The second options would be to add a script to the player's object where you call a function which updates the transform component of the main camera, again only on the local client. Both options are more or less an equal solution. Important is, that the main camera is not a networked object and that you most likely have just one active camera in the same, unless you need a different behaviour.
  • Hey @Christian_Simon !
    Thanks for responding!

    I'm not sure if I fixed it or not (or if this is the correct way to handle it but I'd love your feedback!

    So what happens in my scene?

    - I have 1 camera, which is also my main camera, in the scene which is under a pivot gameobject and that one is under the freelookCamera gameobject.
    The scripts are on the parent (freelookcamera) gameobject with the photon view script (the owner says Scene and i've put it on Request with the observed component being "none". The main camera or pivot doesn't have any special components attached otherwise.

    - The player gets spawned and has the third person network script attached here I've put in the void Awake method:
    void Awake()
    controllerScript = GetComponent();
    cameraPlayer = GameObject.Find("FreeLookCameraRig");
    if (photonView.isMine)

    if (PhotonNetwork.networkingPeer.State == ClientState.Joined)
    Debug.Log("Player Joined so: " + cameraPlayer.GetPhotonView());
    //MINE: local player, simply enable the local scripts
    controllerScript.enabled = true;
    controllerScript.enabled = true;
    controllerScript.isControllable = false;
    } = + photonView.viewID;

    So I presume I'm first checking if it's me in Photonview.isMine and if it is I check another time at the time the player joins (Right?) I find the cameraPlayer gameobject (which is my freelookCameraRig) and request ownership to the photonview component attached.

    Does this seem correct or is it a horrible way/inefficient way of doing things?
    I found it on the forum and it works, i'm not 100% if it should work or how it really works but it does... :/

    Could anyone help me out so others might find this possible solution as well?
  • Hmm my latest (extensive) post seems to have been removed after I tried editing it to include an extra picture? Weird?
  • Hi @Icezman,

    Hmm my latest (extensive) post seems to have been removed after I tried editing it to include an extra picture? Weird?

    Is it the one above? Looks new to me.

    The problem with your new approach is, that whenever a player object gets instantiated, this player will request the ownership of the camera. If this is a wanted behaviour, I think you are fine with it. I honestly can't remember what you want to achieve, so can you please describe me the scenario once again, if it differs from the above behaviour?
Sign In or Register to comment.