Instance Method

look(at:from:upVector:relativeTo:)

Positions and orients the entity towards a target from a given position.

Declaration

func look(at target: SIMD3<Float>, from position: SIMD3<Float>, upVector: SIMD3<Float> = SIMD3<Float>(0, 1, 0), relativeTo referenceEntity: Entity?)

Parameters

target

The target position to look at.

position

The new position of the entity.

upVector

The up direction of the entity after it moves.

referenceEntity

The entity that defines a frame of reference. Set this to nil to indicate world space.

Discussion

You can use this method on any entity, but it’s particularly useful for orienting cameras and lights to aim at a particular point in space.

See Also

Moving an Entity

func move(to: Transform, relativeTo: Entity?)

Moves an entity instantly to a new location given by a transform.

func move(to: float4x4, relativeTo: Entity?)

Moves an entity instantly to a new location given by a 4x4 matrix.