Skip to content

Format

typescript
Transform.SetParent(parent, keep_world_position)

class: Transform

Description

Sets the parent object of the current Transform.

Parameters

param_nametypedescription
parentTransformThe parent Transform.
keep_world_positionboolean?Whether to keep the world space coordinates.

Return

typedescription
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);