The LocalTransform component represents the transform of an entity, and entity transform hierarchies are formed with three additional components:
- The
Parentcomponent stores the id of the entity's parent. - The
Childdynamic buffer component stores the ids of the entity's children. - The
PreviousParentcomponent stores a copy of the id of the entity's parent.
To modify the transform hierarchy:
- Add the
Parentcomponent to parent an entity. - Remove an entity's
Parentcomponent to de-parent it. - Set an entity's
Parentcomponent to change its parent.
The ParentSystem updates the Child and PreviousParent components to ensure that:
- Every entity with a parent has a
PreviousParentcomponent that references the parent. - Every entity with one or more children has a
Childbuffer component that references all of its children.
| ⚠ IMPORTANT |
|---|
Although you can safely read an entity's Child buffer component, you should not modify it directly. Only modify the transform hierarchy by setting the entities' Parent components. |
Every frame, the LocalToWorldSystem computes each entity's world-space transform (from the LocalTransform components of the entity and its ancestors) and assigns it to the entity's LocalToWorld component.
| 📝 NOTE |
|---|
The Entity.Graphics systems read the LocalToWorld component but not any of the other transform components, so LocalToWorld is the only transform component an entity needs to be rendered. |