Skip to content

API Class NavAgent

github-actions[bot] edited this page Dec 2, 2026 · 3 revisions

Class: NavAgent

Defined in: src/plugins/navigation/runtime/components.ts:184

A navigation agent: walks, flies or both by its agent type, avoiding other agents. With updatePosition / updateRotation off, the node is left alone (drive it yourself from desiredVelocity).

Extends

Constructors

Constructor

new NavAgent(): NavAgent;

Returns

NavAgent

Inherited from

Component.constructor

Properties

agentType

agentType: string = "";

Defined in: src/plugins/navigation/runtime/components.ts:186

The agent type's id (project settings); "" = the first type.


areaCosts

areaCosts: Record<string, number | "excluded"> = {};

Defined in: src/plugins/navigation/runtime/components.ts:196

Per-area costs over the type's: { areaId: cost | "excluded" }.


chaseGoal

chaseGoal: boolean = false;

Defined in: src/plugins/navigation/runtime/components.ts:200

Chase initialGoal (follow it as it moves) instead of going to where it is once.


chaseRepathDistance

chaseRepathDistance: number = 1;

Defined in: src/plugins/navigation/runtime/components.ts:202

While chasing initialGoal: plan a new path once it has moved this far (metres).


initialGoal

initialGoal: GameObject | null = null;

Defined in: src/plugins/navigation/runtime/components.ts:198

Where the agent heads as soon as it starts (Foxfire's NavAgentAuthoring InitialGoal); null = nowhere.


priority

priority: number = -1;

Defined in: src/plugins/navigation/runtime/components.ts:194

Avoidance priority; −1 = the type's. (Avoidance layers are the type's, as in Foxfire.)


speed

speed: number = 0;

Defined in: src/plugins/navigation/runtime/components.ts:188

0 = the type's.


turnSpeed

turnSpeed: number = 0;

Defined in: src/plugins/navigation/runtime/components.ts:190

0 = the type's.


updatePosition

updatePosition: boolean = true;

Defined in: src/plugins/navigation/runtime/components.ts:191


updateRotation

updateRotation: boolean = true;

Defined in: src/plugins/navigation/runtime/components.ts:192

Accessors

desiredVelocity

Get Signature

get desiredVelocity(): Vector3;

Defined in: src/plugins/navigation/runtime/components.ts:249

The velocity the agent wants (before avoidance limits; what to drive a node with). A copy.

Returns

Vector3


enabled

Get Signature

get enabled(): boolean;

Defined in: src/engine/core/Component.ts:63

Returns

boolean

Set Signature

set enabled(value): void;

Defined in: src/engine/core/Component.ts:67

Parameters
value

boolean

Returns

void

Inherited from

Component.enabled


gameObject

Get Signature

get gameObject(): GameObject;

Defined in: src/engine/core/Component.ts:43

Unity-style alias for node.

Returns

GameObject

Inherited from

Component.gameObject


isActiveAndEnabled

Get Signature

get isActiveAndEnabled(): boolean;

Defined in: src/engine/core/Component.ts:74

True when enabled, the node is active in the hierarchy, and the node is in a loaded world.

Returns

boolean

Inherited from

Component.isActiveAndEnabled


isWaitingForChunk

Get Signature

get isWaitingForChunk(): boolean;

Defined in: src/plugins/navigation/runtime/components.ts:260

True while the agent waits for its chunk to load.

Returns

boolean


mode

Get Signature

get mode(): NavMode;

Defined in: src/plugins/navigation/runtime/components.ts:238

Returns

NavMode


node

Get Signature

get node(): GameObject;

Defined in: src/engine/core/Component.ts:38

The node this component is on.

Returns

GameObject

Inherited from

Component.node


owner

Get Signature

get owner(): GameObject;

Defined in: src/engine/core/Component.ts:51

The node this component acts for: the node itself when attached directly, or the parent node when this component lives on a component node (ADR 0009).

Returns

GameObject

Inherited from

Component.owner


path

Get Signature

get path(): NavWaypoint[];

Defined in: src/plugins/navigation/runtime/components.ts:265

The current path's waypoints (empty without one).

Returns

NavWaypoint[]


pathState

Get Signature

get pathState(): NavPathState;

Defined in: src/plugins/navigation/runtime/components.ts:234

Returns

NavPathState


remainingDistance

Get Signature

get remainingDistance(): number;

Defined in: src/plugins/navigation/runtime/components.ts:255

Distance left along the path.

Returns

number


time

Get Signature

get time(): Readonly<TimeState>;

Defined in: src/engine/core/Component.ts:99

This component's World's clock (ADR 0032): the same values as Time, but safe to read outside the World's frame too (after an await, say).

Returns

Readonly<TimeState>

Inherited from

Component.time


transform

Get Signature

get transform(): Transform;

Defined in: src/engine/core/Component.ts:57

The Transform of the node this component is on, if it has one.

Returns

Transform

Inherited from

Component.transform


velocity

Get Signature

get velocity(): Vector3;

Defined in: src/plugins/navigation/runtime/components.ts:243

Velocity in the last step (units/s). A copy.

Returns

Vector3


world

Get Signature

get world(): WorldHandle;

Defined in: src/engine/core/Component.ts:88

A handle on this component's World (ADR 0132): the same one Engine.findWorld returns. Load a scene into it, pause, connect or destroy it: this.world.loadScene("scenes/level2.scene.json"). Throws for a World no Engine owns.

Returns

WorldHandle

Inherited from

Component.world

Methods

chase()

chase(node, repathDistance?): void;

Defined in: src/plugins/navigation/runtime/components.ts:219

Follows node (another agent, a NavSurround / NavFlowGoal target, or any node), planning a new path whenever it has moved repathDistance metres (default 1) from where the current path ends.

Parameters

node

GameObject

repathDistance?

number = 1

Returns

void


instantiate()

instantiate(prefabPath, options?): GameObject;

Defined in: src/engine/core/Component.ts:109

Instantiate a prefab in this component's World (ADR 0034), like GameObject.instantiate. Use it in code that may run after an await: by then the frame is over and the current World is the Engine's default one, which may not be this component's. A parent from another World throws.

Parameters

prefabPath

string

options?

InstantiateOptions = {}

Returns

GameObject

Inherited from

Component.instantiate


setDestination()

setDestination(point): void;

Defined in: src/plugins/navigation/runtime/components.ts:211

Plans a path to point and follows it.

Parameters

point

Vec3Input

Returns

void


stop()

stop(): void;

Defined in: src/plugins/navigation/runtime/components.ts:225

Drops the path or chase and stops.

Returns

void


warp()

warp(point): void;

Defined in: src/plugins/navigation/runtime/components.ts:230

Moves the agent to point at once (snapped to the navmesh), dropping its path.

Parameters

point

Vec3Input

Returns

void

Clone this wiki locally