Talos docs

NavAgent

Since 0.6

Present on ctx.nav when the entity has a nav-agent component.

Plain text

Steering itself runs in Rust.

Reached in a behaviour as ctx.nav.

Signature

export interface NavAgent {
  /** Start moving toward `target` along the navmesh at `speed` m/s (the agent's default when omitted). */
  goTo(target: Target, speed?: number): void
  stop(): void
  /** True once within the agent's arrival radius of the target. */
  readonly arrived: boolean
  /** True when the agent has made no progress for a while; the playtester reports this. */
  readonly stuck: boolean
  readonly target: Vec3 | null
}

Import: import type { NavAgent } from "@argus/api"

Members

MemberSignatureDescription
goTogoTo(target: Target, speed?: number): voidStart moving toward target along the navmesh at speed m/s (the agent's default when omitted).
stopstop(): void
arrivedreadonly arrived: booleanTrue once within the agent's arrival radius of the target.
stuckreadonly stuck: booleanTrue when the agent has made no progress for a while; the playtester reports this.
targetreadonly target: Vec3 | null

Example

The tested fixture fixtures/app/agent.ts.

import type { Behavior } from "@argus/api"

// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
  init(ctx) {
    ctx.state.arrived = false
    ctx.nav?.goTo(ctx.props.target as [number, number, number])
  },
  update(ctx) {
    if (ctx.nav?.arrived) ctx.state.arrived = true
  },
} satisfies Behavior