instantiate object inside of object Unity
var newObj = GameObject.Instantiate(somePrefabReference);
newObj.transform.parent = GameObject.Find("EmptyGameObject").transform;
instantiate object inside of object Unity
var newObj = GameObject.Instantiate(somePrefabReference);
newObj.transform.parent = GameObject.Find("EmptyGameObject").transform;
instantiate object inside of object Unity
// Makes the camera follow this object by
// making it a child of this transform.
// Get the transform of the camera
var cameraTransform = Camera.main.transform;
// make it a child of the current object
cameraTransform.parent = transform;
// place it behind the current object
cameraTransform.localPosition = -Vector3.forward * 5;
// make it point towards the object
cameraTransform.LookAt(transform);
instantiate object inside of object Unity
// 1. create game object
// 2. set its transform.parent property
GameObject child = GameObject.Instantiate(MyPrefab);
child.transform.parent = this.gameObject.transform; //or whatever gameobj will be its parent
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us