photonplayer.find returns null

I am trying to get photonplayer by viewid.

PhotonPlayer pl = PhotonPlayer.Find(PlayerSender.GetComponent().viewID);
Debug.Log(pl);

But this is returning null eventhough playersender has photonview

Comments

  • When in your game do you ask for the player? If you do this is any Start() or Awake() or even a bit later it might happen that the photonView is not fully initialized. When i came upon that problem I built my initialization functions into a coroutine. This way you can simply check if the player exists already and if not you can simply wait one frame and try again. Then you can be sure that at a certain point the photon views player will be there.
Sign In or Register to comment.