Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

unity3d change parent of gameobject

public GameObject Child;
public Transform NewParent;

// Sets "newParent" as the new parent of the child GameObject.
Child.transform.SetParent(NewParent);

// Removes parent, puts child into a top-level object in the hierarchy
Child.transform.SetParent(null);
 
PREVIOUS NEXT
Tagged: #change #parent #gameobject
ADD COMMENT
Topic
Name
1+4 =