Horje
instantiate object inside of object Unity Code Example
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
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);




Csharp

Related
convert list to ienumerable Code Example convert list to ienumerable Code Example
c# edit element in list Code Example c# edit element in list Code Example
Local to global position unity Code Example Local to global position unity Code Example
instantiate gameobject as child Code Example instantiate gameobject as child Code Example
should i learn c # Code Example should i learn c # Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8