# SetParent Set the parent transform. ## Syntax ```cpp void SetParent(TransformComponent* parent, bool worldPositionStays = true); ``` ## Parameters - `parent` - The new parent transform, or `nullptr` to detach from parent. - `worldPositionStays` - If `true`, the world position remains unchanged after reparenting. ## Remarks Sets the parent of this transform. When `worldPositionStays` is `true`, the world position is preserved, which may adjust the local position. When `false`, the local position is preserved, which may adjust the world position. ## See Also - [GetParent](get-parent) - [DetachChildren](detach-children) ## Examples ```cpp void Example(TransformComponent* child, TransformComponent* newParent) { child->SetParent(newParent, true); } ```