Skip to main content

Interface ILookAtCommandInvoker

Invoker contract for gaze-orientation commands: directs an actor to look at a world position or transform for an optional duration, independent of the underlying IK system.

public interface ILookAtCommandInvoker : IHasUnityContext

Implements​

IHasUnityContext

Examples​

// Resolve the invoker from a pedestrian actor at the start of an scenario:
ILookAtCommandInvoker lookInvoker = pedestrianGO.GetComponent();

// Track an approaching vehicle until explicitly cancelled (indefinite hold):
lookInvoker.LookAtTransform(vehicleTransform);

// Or hold the gaze for a fixed duration, then release automatically:
lookInvoker.LookAtTransform(vehicleTransform, 2.5f);

// Cancel the gaze once the vehicle has passed the pedestrian:
lookInvoker.CancelLookAtCommand();

Remarks​

Using this interface lets scenario scripts issue the look-at command without knowing whether the character uses Unity Animation Rigging, Cinemachine look-at, or a custom IK solver.

A negative duration (the default) signals an indefinite hold until CancelLookAtCommand is called, which matches the common case of "keep looking at the car until it passes".

Methods​

CancelLookAtCommand()​

Cancels the active look-at command and returns the actor to its default gaze orientation.

void CancelLookAtCommand()

LookAtPosition(Vector3, float)​

Commands the actor to orient its gaze toward a fixed world-space position.

void LookAtPosition(Vector3 lookAtPosition, float duration = -1)

Parameters​

NameTypeDescription
lookAtPositionVector3The world-space position to look at.
durationfloatSeconds to hold the gaze; a negative value holds indefinitely until CancelLookAtCommand is called.

LookAtTransform(Transform, float)​

Commands the actor to orient its gaze toward a transform, re-evaluating the target each frame so the gaze tracks if the target moves.

void LookAtTransform(Transform lookAtTransform, float duration = -1)

Parameters​

NameTypeDescription
lookAtTransformTransformThe transform to track.
durationfloatSeconds to hold the gaze; a negative value holds indefinitely until CancelLookAtCommand is called.