Contents

setParent(_:preservingWorldTransform:)

Attaches the entity as a child to the specified entity.

Declaration

@MainActor @preconcurrency func setParent(_ parent: Entity?, preservingWorldTransform: Bool = false)

Parameters

  • parent:

    The new parent entity. Use nil to detach the entity from its current parent.

  • preservingWorldTransform:

    A Boolean that you set to true to preserve the entity’s world transform, or false to preserve its relative transform. Use true when you want a model to keep its effective location and size within a scene.

Discussion

Attaching an entity to a new parent automatically detaches it from its old parent.

The children collections of both the old and new parent are automatically updated as well.

See Also

Managing the parent