Skip to content

Latest commit

 

History

History
32 lines (21 loc) · 2.73 KB

transforms.md

File metadata and controls

32 lines (21 loc) · 2.73 KB

Transform components and systems

The LocalTransform component represents the transform of an entity, and entity transform hierarchies are formed with three additional components:

  • The Parent component stores the id of the entity's parent.
  • The Child dynamic buffer component stores the ids of the entity's children.
  • The PreviousParent component stores a copy of the id of the entity's parent.

To modify the transform hierarchy:

  • Add the Parent component to parent an entity.
  • Remove an entity's Parent component to de-parent it.
  • Set an entity's Parent component to change its parent.

The ParentSystem updates the Child and PreviousParent components as needed, such that:

  • Every entity with a parent has a Parent component that references the parent.
  • Every entity with one or more children has a Child buffer 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.

The ITransformDataHelpers class provides static methods for producing and manipulating transforms.

The TransformAspect provides a convenient abstraction for working with an entity's transform components.