Hello! I am working on a multiplayer game. I have this script:
using UnityEngine;
using System.Collections;
public class ActiveSetter : Photon.MonoBehaviour {
public GameObject PlayerCamera;
public UnityStandardAssets.Characters.FirstPerson.FirstPersonController script;
public CharacterController CharController;
public HealthManagerCS HealthManager;
public BuilderScriptCS BuilderScript;
// Use this for initialization
void Start () {
if(!photonView.isMine){
Debug.Log ("photonView.isMine is false!");
PlayerCamera.SetActive(false);
script.enabled = false;
CharController.enabled = false;
HealthManager.enabled = false;
BuilderScript.enabled = false;
}
else{
PlayerCamera.SetActive(true);
script.enabled = true;
CharController.enabled = true;
HealthManager.enabled = true;
BuilderScript.enabled = true;
}
}
// Update is called once per frame
void Update () {
}
}
However, when I play the game, the other player prefab cameras are still activated, even if photonView.isMine = false. It was working fine, then it suddenly stopped. The player prefabs are instantiated with PhotonNetwork.Instantiate(); if that makes a difference. I assigned the variables in the project view. I went to my player prefab, and then I dragged the camera into that variable of the script.
Thanks in advanced!
Edit: The other players’ cameras being on is significant because it overrides the other cameras in the scene, so all players are watching the same camera as opposed to their own player camera.