Format
typescript
Transform.SetParent(parent, keep_world_position)class: Transform
Description
Sets the parent object of the current Transform.
Parameters
| param_name | type | description |
|---|---|---|
| parent | Transform | The parent Transform. |
| keep_world_position | boolean? | Whether to keep the world space coordinates. |
Return
| type | description |
|---|---|
void |
Code Example
typescript
let parent = new GameObject("parent");
let child = new GameObject("child");
// Set parent as the parent object of child
child.transform.SetParent(parent.transform);