convertTransformTo

@MainThread
fun convertTransformTo(transform: Transform, targetEntity: Entity?): Transform

Converts a Transform relative to the current entity to a targetEntity.

Attention: "relative to" an Entity is different from "in the local coordinate system/space of" the Entity. You may use the converted result to place an entity when you need a transform in that entity's local coordinate space. In this case, the proper targetEntity should be the parent of the entity to place. For example, if entityA and entityB are in different coordinate spaces, and transformA is relative to entityA, pass entityB's parent as targetEntity when placing entityB with transformA.

entityB.components.set(TransformComponent(entityA.convertTransformTo(transformA.position,
entityB.getParent()))

Return

The converted Transform relative to targetEntity, or relative to the current entity's SpatialContainer when targetEntity is null.

Parameters

transform

The Transform relative to the current entity.

targetEntity

The target entity to which the Transform will be converted. If null, the Transform is converted relative to the SpatialContainer where the current entity is placed.