photonView.owner.TagObject = gameObject; Not Working
Options
Hi,
I'm trying to acces the gameobject that has the photon view on it by putting this line in the start function: photonView.owner.TagObject = gameObject;
and then I want to acces that objects "DidIDie" script and change it's boolean from another script on another object in the scene like so:
PhotonPlayer p = photonView.owner;
var playerPrefabObject = p.TagObject as GameObject;
playerPrefabObject.GetComponent<DidIDie>().IDied= true;
For now I'm just doing this in update but I want it to be in an if statement, but I'm getting a null reference error on " var playerPrefabObject = p.TagObject as GameObject;"
If I do it like this it's the exact same frustrating null reference error:
PhotonPlayer p = photonView.owner;
GameObject GO = p.TagObject as GameObject;
Go.GetComponent<DidIDie>().IDied= true;
I'm reading that this works for others, is it because I'm using PUN ? Why doesn't this work and why does it have to be so difficult to acces the gameobject that has the photon view on it?
I'm trying to acces the gameobject that has the photon view on it by putting this line in the start function: photonView.owner.TagObject = gameObject;
and then I want to acces that objects "DidIDie" script and change it's boolean from another script on another object in the scene like so:
PhotonPlayer p = photonView.owner;
var playerPrefabObject = p.TagObject as GameObject;
playerPrefabObject.GetComponent<DidIDie>().IDied= true;
For now I'm just doing this in update but I want it to be in an if statement, but I'm getting a null reference error on " var playerPrefabObject = p.TagObject as GameObject;"
If I do it like this it's the exact same frustrating null reference error:
PhotonPlayer p = photonView.owner;
GameObject GO = p.TagObject as GameObject;
Go.GetComponent<DidIDie>().IDied= true;
I'm reading that this works for others, is it because I'm using PUN ? Why doesn't this work and why does it have to be so difficult to acces the gameobject that has the photon view on it?
0