FollowPathAction

Agent action that sequentially moves the character through all waypoints in an AgentPath. Creates a MoveToTargetAction sub-action and executes it for each waypoint in order.

Definition

Namespace: Paragon.Townskeep.AgentSystem Assembly: Townskeep.dll

public class FollowPathAction : AgentAction

Inheritance: ActionAgentAction → FollowPathAction

Remarks

FollowPathAction is a higher-order action that composes MoveToTargetAction to visit each waypoint in an AgentPath. The path is bound via the [Variable] attribute, making it configurable from the Inspector or through the action variable system.

Execution Flow

  1. OnBegin — Creates a new MoveToTargetAction and initializes it with the agent context

  2. OnExecute — Iterates from index 0 to path.Size - 1:

    • Sets the MoveToTargetAction's target to path[i] (child transform position)

    • Awaits moveAction.ExecuteAsync() — the character navigates to the waypoint

  3. Completes when all waypoints have been visited

The same MoveToTargetAction instance is reused for all waypoints — only the target position is updated each iteration.

Quick Lookup

Goal
How

Assign a path

Set the path variable via Inspector or action.SetVariable("path", agentPath)

Follow the path

await followPathAction.ExecuteAsync()

Fields

Field
Type
Access
Description

path

AgentPath

[Variable] private

The waypoint path to follow

Extension Points

This is a concrete (non-abstract) action. Override lifecycle hooks from Action if subclassing:

Method
Purpose

OnBegin()

Creates and initializes the MoveToTargetAction sub-action

OnExecute()

Iterates waypoints and awaits movement to each one

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation

Examples

Inspector Setup

  1. Add FollowPathAction to an agent's ActionSequence in the Inspector

  2. Create a GameObject with an AgentPath component

  3. Add child GameObjects as waypoints (their positions define the path)

  4. Assign the AgentPath to the path variable

Programmatic Usage

See Also

Last updated