lookAt method

void lookAt(
  1. Vector3 target, {
  2. Vector3? up,
})

Orients this node so its forward axis (local +Z) points at target in world space, keeping up as the reference up (defaults to +Y). Only the node's rotation changes; its world position and scale are preserved.

+Z is the engine's forward convention: cameras look down it, directional and spot lights aim down it, and imported models face it, so this aims any of them. up must not be parallel to the direction from the node to target; for a straight-down or straight-up view pass Vector3(0, 0, 1) or Vector3(0, 0, -1) instead of Vector3(0, 1, 0).

Implementation

void lookAt(Vector3 target, {Vector3? up}) =>
    lookAtFrom(globalTransform.getTranslation(), target, up: up);