Files
XCEngine/docs/api/components/transform-component/set-parent.md
ssdfasd a9d5a68dd6 docs: Add Component, GameObject, TransformComponent and Scene API documentation
- Add Component class documentation with lifecycle methods
- Add GameObject class documentation with component system
- Add TransformComponent documentation with transform methods
- Add Scene class documentation with GameObject management
- Add SceneManager singleton documentation with scene loading
- Update components.md overview with all component classes
- Update main.md navigation with Scene module
2026-03-22 03:33:55 +08:00

32 lines
775 B
Markdown

# 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);
}
```