LookAtAction
Agent action that instantly rotates and orients the character to face a target item. Uses the character's controller to set both body rotation and look-at direction in a single frame.
Definition
Namespace: Paragon.Townskeep.AgentSystem
Assembly: Townskeep.dll
public class LookAtAction : AgentActionInheritance: Action → AgentAction → LookAtAction
Remarks
LookAtAction is a synchronous, single-frame action that snaps the character's orientation toward a target item. It is typically used before GrabItemAction in a sequence so the character faces the item before picking it up.
Execution Flow
Two-Step Orientation
The action performs two distinct controller operations:
RotateTo — rotates the character's body to face the target position (yaw rotation)
LookAt — sets the character's head/eye look-at target (for IK or camera)
Both operations use the item's transform.position as the target point.
Quick Lookup
Face the character toward an item
Add LookAtAction to sequence; ensure "Item" variable is set
Combine with grab
Place LookAtAction before GrabItemAction in the sequence
Fields
item
Item
[Variable] private
The target item to look at; bound from sequence variables
Methods
OnExecute
Rotates the character body toward the item and sets the look-at target. Returns synchronously.
Returns: Task.CompletedTask — this action completes instantly.
Common Pitfalls
No null check on item
Unlike GrabItemAction, LookAtAction does not check if item is null before accessing item.transform.position. If the "Item" variable is not set, this will throw a NullReferenceException.
Instant snap, no interpolation
Both RotateTo and LookAt are applied in a single frame with no smoothing. The character will snap to face the target instantly. For gradual turning, use MoveToTargetAction's RotateTowards instead.
No OnBegin override
This action does not override OnBegin(). All logic runs in OnExecute(), meaning there is no setup phase. The item variable must already be set when execution begins.
See Also
AgentAction — abstract base with agent context
GrabItemAction — typically follows this action in a sequence
MoveToTargetAction — handles gradual rotation during movement
Actions Overview — subsystem architecture
Last updated