Navigation · class

NavPath

A route being walked: the nodes, and how far along them the agent is.

Explained in Navigation.

class NavPath
import { 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)
ParameterTypeDescription
graphNavGraph
capacitynumber
options?NavPathOptions

Accessors

NameTypeDescription
nodeCountgetnumber
lengthMgetnumber
activegetbooleanWhether there is a route to follow at all.

Methods

set

set(path: Uint32Array, count: number): void

Take a route, as NavSearch.find filled it.

ParameterTypeDescription
pathUint32Array
countnumber
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(): void

steer

steer(x: number, y: number, z: number, out: NavSteer): void

Where an agent at (x, y, z) should aim next.

ParameterTypeDescription
xnumber
ynumber
znumber
outNavSteer
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.