creating child objects during run time

is there any way to attach child objects to another object during run time? i can’t seem to find any way to do this.

Also, are there any built in functions to apply the familiar unity spatial relations to arbitrary Vector3s? This is something I could write myself but it would take a lot of time and would probably not be very efficient.

thanks in advance.

Yeah, there is.

// Attach gameobject to another gameobject

// Find your child object by name in the scene
GameObject objToAttachToParent = GameObject.Find("TheObjectYouWantToAttach");

// Attach it to the GameObject this script is attached to
objToAttachToParent.transform.parent = gameObject;

Hope that helps.

Yeah, thats exactly what I was looking for thakns!