Photon - 2 Characters, One Camera

We are creating a basic multiplayer game. The issue is difficult to explain.

Computer #1 / Player #1: Host of the game, spawn players fine, camera is attached appropriately.

When a second player joins the game, Computer #2 now controls the camera (appears to be only one in the scene, but each player should have their own).

Computer #1 now sees itself in 3rd person and the camera is controlled by Computer #2.

Computer #1 can still move their own character, but it is no longer a first person point of view.

Any suggestions on what the problem could be?

Include code for spawning the player and attaching the camera and it will be easier to help. It sounds like the camera attachment is potentially networked when it should be happening locally, thus player 2 is hijacking the camera from 1. Without code though, I can’t really give you a decent answer.

Hello Zaladur,

Attached is where I think this is happening. We are using Photon we didn’t write this code, but looking at it, it appears to do something with the “Main Camera”. This “Main Camera” is a child of the “PlayerController” Prefab.

void SpawnMyPlayer(int teamID) {
        this.teamID = teamID;
        hasPickedTeam = true;
        AddChatMessage("Spawning player: " + PhotonNetwork.player.name);

        if(spawnSpots == null) {
            Debug.LogError ("WTF?!?!?");
            return;
        }

        SpawnSpot mySpawnSpot = spawnSpots[ Random.Range (0, spawnSpots.Length) ];
        GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
        standbyCamera.SetActive(false);

        //((MonoBehaviour)myPlayerGO.GetComponent("FPSInputController")).enabled = true;
        ((MonoBehaviour)myPlayerGO.GetComponent("MouseLook")).enabled = true;
        ((MonoBehaviour)myPlayerGO.GetComponent("PlayerMovement")).enabled = true;
        //((MonoBehaviour)myPlayerGO.GetComponent("PlayerShooting")).enabled = true;

        myPlayerGO.GetComponent<TeamMember>().teamID = teamID;
        SkinnedMeshRenderer mySkin = myPlayerGO.transform.GetComponentInChildren<SkinnedMeshRenderer>();

        if(mySkin == null) {
            Debug.LogError("Couldn't find a SkinnedMeshRenderer!");
        }

        if(teamID==1)
            mySkin.material.color = Color.red;
        if(teamID==2)
            mySkin.material.color = new Color(.5f, 1f, .5f);

        myPlayerGO.transform.FindChild("Main Camera").gameObject.SetActive(true);
    }

I presume this function is a RPC function ; so every player connected will call this function.

Player 1 connects ; creates a character, turns on the camera and the controller
Player 2 connects ; creates a character, Player 1 also receives the RPC and turns on the camera of the new created character but still has the control of the first character. Do you understand what I mean ?

You have to check if the character is “my” character (isMine) ; if it is my character (I AM the one who instantiates the character), enable the camera and the controller. If not, disable the camera and the controller.

Edit: okay, I just saw you set “enable” to true. Let me re-check what you did D: Can you take a screenshot of the project hierarchy when you instantiated 2 characters ? With their children visible.

Edit²: when do you call this function ?