Cameras Not Changing

Options
For some reason, this code is being weird. It moves each player correctly so I know its reading the code, but its not changing the camera for each player. If I'm understanding correctly, the camera I'm not using should be disabled and the camera I'm using should be enabled, yet both players are set to MainCamera2. Also, I tried the code I commented out and they didn't work either. Thanks in advance.
playerInfo = gameObject.GetComponent<PlayerInfo>();
		if(playerInfo.playerNumber == 2)
		{
			gameObject.transform.position = new Vector3(137, 7, 152);
			gameObject.transform.rotation = Quaternion.Euler(0, 165, 0);
			MainCamera2.GetComponent<Camera>().enabled = true;
			OtherCamera.GetComponent<Camera>().enabled = false;
			//MainCamera2.camera.enabled = true;
			//OtherCamera.camera.enabled = false;
		}
		else
		{
			gameObject.transform.position = new Vector3(98, 7, 116);
			gameObject.transform.rotation = Quaternion.Euler(0, 20, 0);
			MainCamera2.GetComponent<Camera>().enabled = false;
			OtherCamera.GetComponent<Camera>().enabled = true;
			//MainCamera2.camera.enabled = false;
			//OtherCamera.camera.enabled = true;
		}

Comments

  • Do you have your camera controller attached to the player object?
  • I attach this script to the player, and then I manually add the cameras to the code using:
    public GameObject MainCamera2;
    	public GameObject OtherCamera;
    
    The cameras are both put into the scene afterwards.
  • Tobias
    Options
    Per instantiated character, you have to check if it's yours or belonging to another player. Use PhotonView.isMine to check, not "playerInfo.playerNumber == 2".