Error finding photonPlayer
marf
✭
Hi, I have this code:
That have the function to find the PhotonPlayer that I have attacked.
This is called after that a RayCastHit hit the player,
says correctly the name of the player, but
says a NullReferenceException: Object reference not set to an instance of an object
I think that there is an error while I'm finding the player, any suggest?
P.S. There is a photonView attached to the Player prefab.
Marco
PhotonPlayer target = PhotonPlayer.Find(hit.collider.gameObject.GetComponent<PhotonView>().viewID.ID);
That have the function to find the PhotonPlayer that I have attacked.
This is called after that a RayCastHit hit the player,
Debug.Log("Target Name: " + hit.collider.gameObject.name);
says correctly the name of the player, but
Debug.Log("Target: " + target.name);
says a NullReferenceException: Object reference not set to an instance of an object
I think that there is an error while I'm finding the player, any suggest?
P.S. There is a photonView attached to the Player prefab.
Marco
0
Comments
-
What guarantees you that there is even a photonview with attached photon player on the target?
you could hit something where you by error attached a scene photon view which will not have a player0 -
Yeah, I've missed that, I have resolved it thanks.0