Add Child to Other Client GameObject

Options
All Clients Start with a Base GameObject I would like to GameObject go = PhotonNetwork.Instantiate,
and child the newly instantiated go under the Base GameObject "Parent".

I do not have any issue doing this on the client side i.e go.gameObject.transform.parent = GameObject.Find ("Base");
But on the other clients go is still floating around on it's own.

I have looked at RPC(s) but can not seem to understand how to implement them for this.

(go) should child to all the client's base objects.

Comments

  • Figured it out.

    Create Prefab.
    private PhotonView MyPhotonView;
    	void OnJoinedRoom () {
    	   GameObject iCorePrefab = 
                   PhotonNetwork.Instantiate ("iCore", Vector3.zero, Quaternion.identity, 0);
    		         MyPhotonView = iCorePrefab.GetComponent<PhotonView>();
                   this.MyPhotonView.RPC("GitParent", PhotonTargets.AllBuffered);
    				
    	}
    

    Code on Prefab
    [RPC]
    	void GitParent(){
    		Debug.Log ("RPC Test");
    		this.gameObject.transform.parent = GameObject.Find ("Base").transform;
    	}
    
  • Tobias
    Options
    If you always parent the new GO this way, why don't you do this in a script in Awake()? Just add it to the prefab and you're done. Saves you a network message.
  • I will try that, GO needs to child itself under new/other clients base object as well.

    Also Thanks for the Support!
  • Jimbones
    Options
    This is exactly what I'm trying to do with mine as well. I've been so far unsuccessful in trying what @Tobias suggested. Do you by chance happen to recall whether or not you were able to get it to work without the RPC @CoreWorkNode ?
  • Jimbones
    Options
    Ugh...sorry guys, never mind. I should've mentioned that I'm using VRTK and I realized that since there is only one available camerarig/SDK manager available in the scene to parent to, it isn't going to work the same way as a typical non VR setup. Though it ends up looking a bit odd in the Unity hierarchy window, I was able to sort my issue using a Transform Follow script. :)
  • Jimbones
    Options
    Ugh...sorry guys, never mind. I should've mentioned that I'm using VRTK and I realized that since there is only one available camerarig/SDK manager available in the scene to parent to, it isn't going to work the same way as a typical non VR setup. Though it ends up looking a bit odd in the Unity hierarchy window, I was able to get it to work just fine. :)