Accessing remote object created with InstantiateSceneObject

Options
Hello all,

I've created a remote object with the following line:

PhotonNetwork.InstantiateSceneObject("Ball", new Vector3(5.0f, 3.0f, 2.0f), Quaternion.identity, 0, null);

I can see the scene object in the scene on the master client which created it and the other remote scenes. The problem I'm having is I need a reference to the scene object because remote clients need to interact with it as well. On the master client I can find the scene object GameObject like any normal GameObject (Find, FindWithTag, etc). However, on the remote clients these methods return null. For example:

On client which create scene object:
GameObject ball = GameObject.Find("Ball(Clone)"); // returns GameObject

On remote client:
GameObject ball = GameObject.Find("Ball(Clone)"); // returns null

Please help any assistance would be greatly appreciated!

Comments

  • vadim
    Options
    Hi,

    Handle OnPhotonInstantiate message (implement OnPhotonInstantiate()) in one of object scripts. This handler will be called on object instantiation on every client. Store reference to the object in this handler.
  • Great that worked!!! Thanks!