Class LookCommandInvoker
Class responsible for invoking look at commands. Implements the ILookAtCommandInvoker interface.
public class LookCommandInvoker : MonoBehaviour, ILookAtCommandInvoker, IHasUnityContext
Inheritance
Implements
Examples
The following reproduces the pattern used by ProximityGazer to direct a
pedestrian actor's gaze toward an approaching vehicle and cancel it when the vehicle
leaves the detection zone.
// Resolve the invoker from a pedestrian actor (done once, e.g. in Start/Awake).
LookCommandInvoker lookInvoker = pedestrianGameObject.GetComponent();
// --- Indefinite hold: keep looking until CancelLookAtCommand is called ---
// Used when GazeDuration is not configured; the pedestrian tracks the vehicle
// for as long as it remains in the proximity zone.
lookInvoker.LookAtTransform(vehicleTransform);
// --- Timed hold: look at the vehicle for exactly 2.5 seconds, then release ---
// The LookCommand auto-kills itself after the duration elapses.
lookInvoker.LookAtTransform(vehicleTransform, 2.5f);
// --- Cancel: end the gaze immediately (e.g., when the vehicle leaves the zone) ---
lookInvoker.CancelLookAtCommand();
Remarks
LookCommandInvoker uses DOTween to smoothly blend the Animation Rigging
weight in and out, so the character's head eases into and out of the look pose
rather than snapping. Only one LookCommand is active at a time; starting
a new one replaces the previous command immediately.
A negative duration (the default of -1f) keeps the gaze
locked until CancelLookAtCommand is called explicitly.
Methods
CancelLookAtCommand()
Cancels the current look at command if the invoker is enabled.
public void CancelLookAtCommand()
LookAt(Vector3)
Makes the GameObject look at a specific position.
public void LookAt(Vector3 positoin)
Parameters
| Name | Type | Description |
|---|---|---|
positoin | Vector3 | The position to look at. |