Navigation · class
NavPath
A route being walked: the nodes, and how far along them the agent is.
Explained in Navigation.
class NavPathimport { NavPath } from '@driftengine/nav';In depth
Progress is a distance along the path, not an index into it, and that is what makes this survive an agent being shoved. An index only ever counts up when a waypoint is reached, so an agent knocked backwards past one keeps aiming at the waypoint behind it; a distance is recovered from the agent's own position every update, against the segment it is nearest to, so being pushed about costs progress and never correctness.
Constructor
new
constructor(graph: NavGraph, capacity: number, options?: NavPathOptions)| Parameter | Type | Description |
|---|---|---|
graph | NavGraph | |
capacity | number | |
options? | NavPathOptions |
Accessors
| Name | Type | Description |
|---|---|---|
nodeCountget | number | |
lengthMget | number | |
activeget | boolean | Whether there is a route to follow at all. |
Methods
set
set(path: Uint32Array, count: number): voidTake a route, as NavSearch.find filled it.
| Parameter | Type | Description |
|---|---|---|
path | Uint32Array | |
count | number |
More
A route of one node is a route to where the agent already is, and is stored as no route: it has no direction to steer along and every caller would otherwise have to special-case it.
clear
clear(): voidsteer
steer(x: number, y: number, z: number, out: NavSteer): voidWhere an agent at (x, y, z) should aim next.
| Parameter | Type | Description |
|---|---|---|
x | number | |
y | number | |
z | number | |
out | NavSteer |
More
With no route, the agent is told to aim where it stands and that it has arrived, so a caller
driving off arrived needs no separate check for having no path at all.