AgentPath

Lightweight waypoint path defined by child transforms. Provides indexed access to world-space positions and draws debug lines between waypoints in the Scene view when selected.

Definition

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

public class AgentPath : MonoBehaviour

Inheritance: MonoBehaviour → AgentPath

Remarks

AgentPath is a purely data-driven path definition. It has no runtime behavior — it simply exposes the world-space positions of its child transforms via an indexer and a count property.

How It Works

Each child Transform of the AgentPath GameObject represents a waypoint. The path order is determined by the sibling index of the children (as returned by transform.GetChild(index)). Moving, adding, or reordering children in the hierarchy changes the path.

Scene Visualization

When the AgentPath GameObject is selected in the Scene view, OnDrawGizmosSelected() draws lines between consecutive waypoints, providing a visual preview of the path route.

Intended Usage

AgentPath is consumed by FollowPathAction, which iterates from index 0 to Size - 1 and moves the agent to each waypoint position sequentially.

Quick Lookup

Goal
How

Get waypoint count

path.Size

Get waypoint position

path[index]

Create a path

Add an AgentPath component, create child GameObjects as waypoints

Reorder waypoints

Reorder child GameObjects in the hierarchy

Properties

Size

The number of waypoints in the path (equal to transform.childCount).

this[int index] (Indexer)

Returns the world-space position of the waypoint at the given index.

Parameter
Type
Description

index

int

Waypoint index (0 to Size - 1)

Returns: Vector3 — the world-space position of the child transform at that index.

circle-exclamation

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

Examples

Hierarchy Setup

Accessing Waypoints in Code

Using with FollowPathAction

See Also

Last updated