|
Kanda Interactions 0.7.1
|
Attachables provides a mechanism for attaching entities to other entities, allowing them to follow the movement of their "owner" entity. This system is particularly useful for creating lightweight relationships between entities or for implementing attachment points for equipment, effects and more.
MovableTo attach one entity to another, add an Attachable component to the entity you want to attach:
The AttachableSystem will automatically update the attached entity's position to match its owner.
For attachments that need to maintain their world space position relative to the owner, use world space mode:
To detach an entity, simply set its Attachable.Owner to Entity.Null:
You can temporarily disable the attachment behavior by disabling the Attachable component:
There is a case where we need the attached entity only if over a certain threshold distance to the owner entity. To solve this case we introduced ThresholdAttachable to supplement Attachable that can be used to set the threshold distance to determine if the entity is attached or not.
The AttachableSystem works in tandem with Movables. Attached entities should have both Attachable and Movable components. The AttachableSystem updates the Movable component's target position, which is then processed by the MovableSystem.