info.photonView = null in OnPhotonInstantiate

I am trying to save a reference to the gameObject that instantiated a new object across all clients. I am attempting to do this in the OnPhotonInstantiate(PhotonMessageInfo info) method on a script attached to the newly instantiated object.

However, when I attempt to do '_owner = info.photonView.gameObject', the info.photonView returns null.

Any help would be greatly appreciated. Thanks

Comments

  • Hi,

    the confusion comes from the fact that the info is not about the instantiated object but who created it:

    https://doc-api.photonengine.com/en/pun/current/group__public_api.html#ggaf30bbea51cc8c4b1ddc239d1c5c1468faa8bb589bf7df8d2be1f0b4b586ba8001

    Bye,

    Jean
  • I understand that the info is not about the instantiated object, but who created it. I am attempting to retrieve the photonView of the object that created the instantiated object.
  • I know this is a little late, but for anyone else who comes across this problem, I believe I know whats happening, at least for me.

    When the game starts, I use a "GameManager" script to spawn all players with PhotonNetwork.Instantiate - the object that CALLS PhotonNetwork.Instantiate, doesnt have a PhotonView - therefore, "info" will be null, because the object that created it, was NOT the player that has a PhotonView on it.

    The downside here, is that if I give the "GameManager" script a photonView, it will always return the local client, and not the opposing one, so ill always get the same "info" for both instantiated objects. I believe a way to work around this is to either use customProperties for each player, and temp store info thats unique about that player, then use that, or on your player, use GetComponent() and get it yourself, not relying on "info".