I am trying to use photonView.isMine, but it is not working. I am getting this error.NullReferenceException: Object reference not set to an instance of an object MultiplayerHandler.OnJoinedRoom () (at Assets/Scripts/MultiplayerHandler.cs:20)
Here is my code I am trying to use:
void OnJoinedRoom()
{
GameObject player = PhotonNetwork.Instantiate("ClientPlayer", Vector3.zero, Quaternion.identity, 0);
if (photonView.isMine)
{
(player.GetComponent("CharacterMotor") as MonoBehaviour).enabled = true;
(player.GetComponent("FPSInputController") as MonoBehaviour).enabled = true;
(player.GetComponent("MouseLook")as MonoBehaviour).enabled = true;
}
by the way the it says the error was on this line: if (photonView.isMine)
– TBiggumsThat means the
– Chronos-LphotonVIewis null and not assigned.Excuse my utter noobiness, but how would I make it assigned?
– TBiggumsYou should have this somewhere in your code, and this should be called before
– Chronos-LphotonViewis used: photonView = ...; Or you can have this, then you assign thephotonViewin the inspector (only works if thephotonViewis a component): public TheTypePhotonViewIs photonView;but photonView is a class the comes with Photon. I think isMine is coming back null but I don't know why.
– TBiggums