Instantiate with photonView


I need to instantiate an object with photonview on it, and then parent it via an RPC. However im totally stuck!
This code works fine if the object doesn't need a photonview on it. But i need it to have a photonview on it.
this.photonView.RPC("SomeRPC", PhotonTargets.All, "ModelName");

void SomeRPC(string modelName)
	GameObject modelID;
    modelID = Instantiate(Resources.Load(modelName)) as GameObject;
    modelID.transform.parent = thePlayer;
	modelID.transform.localPosition =;
And if i use PhotonNetwork.Instantiate. I can't find the gameobject i just instantiated..
So basically what i need is to instantiate an object with photonview and then let everybody know the parenting but im lost right now. So i would really appreciate any help!


  • Tobias
    The game object you create is returned by Instantiate:
    GameObject newGo = PhotonNetwork.Instantiate(...)
    You can only instantiate prefabs that are in a "Resources" folder which have a PhotonView attached and only by name.

    In best case, you find some rule for the parenting that doesn't need a RPC.
    Or at least replace the RPC by using the Instantiate overload with the object[] called "data". You could pass the parent and access it when the object gets instantiated.