navKit.maps — bakes a walkable map from the level's colliders (and terrain)
and answers path queries on it through the engine's pathfinding package.
local Maps = require("navKit.maps")
local map = Maps.bake({ kind = "grid", min = { -20, -1, -20 }, max = { 20, 8, 20 } })
local path = map:findPath({ 0, 0, 0 }, { 12, 0, 9 }, { radius = 0.4 })
One bake casts one ray down each column of cells and keeps every floor it
meets (ground, balconies, upper storeys) whose slope and headroom fit an
agent; neighbouring floors within a step height join. From that field:
grid -> the engine's `Pathfinding.gridGraph` over the lowest floor
waypoint -> the engine's `Pathfinding.waypointGraph`, points a few metres
apart joined where a straight walk is clear
layered -> a graph of navKit's own over every floor, implementing the
pathfinding package's graph interface
All three run the package's A*, its cost zones (`Pathfinding.addModifier`,
which is also how navKit obstacles block cells) and its off-mesh links
(`Pathfinding.addLink`, which navKit links register).
noteChange(a: Vec, b: Vec, c: Vec?, d: Vec?) → void
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
| c | Vec? | |
| d | Vec? | |
setObstacle(key: string, mn: any, mx: any) → void
| arg | type | description |
|---|
| key | string | |
| mn | any | |
| mx | any | |
removeObstacle(key: string) → boolean
| arg | type | description |
|---|
| key | string | |
inObstacle(x: number, y: number, z: number, pad: number) → boolean
| arg | type | description |
|---|
| x | number | |
| y | number | |
| z | number | |
| pad | number | |
segmentBlocked(a: Vec, b: Vec, pad: number) → boolean
Does the segment a->b (horizontal) pass through any obstacle box grown by pad?
| arg | type | description |
|---|
| a | Vec | |
| b | Vec | |
| pad | number | |
boundsOf(o: BakeOpts) → void
| arg | type | description |
|---|
| o | BakeOpts | |
autoBounds( ) → void
The box around every static collider in the world (and every terrain),
capped at 400 m a side.
grow(id: string) → void
| arg | type | description |
|---|
| id | string | |
cap(lo: number, hi: number) → void
| arg | type | description |
|---|
| lo | number | |
| hi | number | |
excludeSet(o: BakeOpts) → void
| arg | type | description |
|---|
| o | BakeOpts | |
bake(opts: BakeOpts?) → any
| arg | type | description |
|---|
| opts | BakeOpts? | |
register(map: any) → void
remove(name: string) → boolean
| arg | type | description |
|---|
| name | string | |
get(name: string?) → any
| arg | type | description |
|---|
| name | string? | |
at(p: any) → any
The map whose box holds the point (the smallest one when several do).
contains(p: any) → boolean
column(x: number, z: number) → void
| arg | type | description |
|---|
| x | number | |
| z | number | |
floorAt(x: number, z: number, y: number, reach: number?) → number
The floor node under (x, z) nearest the height y, within `reach` metres.
| arg | type | description |
|---|
| x | number | |
| z | number | |
| y | number | |
| reach | number? | |
heightAt(p: any, reach: number?) → number
| arg | type | description |
|---|
| p | any | |
| reach | number? | |
clearanceAt(p: any) → number
Metres of clear floor around the point (0 at a wall or drop), or nil off the map.
isWalkable(p: any, radius: number?) → boolean
| arg | type | description |
|---|
| p | any | |
| radius | number? | |
nearestNode(p: any, radius: number?, ground: boolean?) → number
Nearest walkable floor node to a point for an agent of this radius.
| arg | type | description |
|---|
| p | any | |
| radius | number? | |
| ground | boolean? | |
nearestPoint(p: any, radius: number?) → Vec
| arg | type | description |
|---|
| p | any | |
| radius | number? | |
clearLine(a: any, b: any, radius: number?) → boolean
Can an agent of `radius` walk straight from a to b? Follows the floor up
ramps and steps, and fails at walls, drops, too-narrow spots and obstacles.
| arg | type | description |
|---|
| a | any | |
| b | any | |
| radius | number? | |
_node(i: number) → any
| arg | type | description |
|---|
| i | number | |
bucket(r: number) → number
| arg | type | description |
|---|
| r | number | |
view(radius: number?, exposure: number?) → any
| arg | type | description |
|---|
| radius | number? | |
| exposure | number? | |
openness(cl: number) → number
| arg | type | description |
|---|
| cl | number | |
_layeredView(r: number, ew: number) → any
| arg | type | description |
|---|
| r | number | |
| ew | number | |
nodeKey(node: any) → string return node
| arg | type | description |
|---|
| node | any | |
position(node: any) → Vec return node
| arg | type | description |
|---|
| node | any | |
adjacent(node: any) → void
| arg | type | description |
|---|
| node | any | |
heuristic(a: any, b: any) → number
| arg | type | description |
|---|
| a | any | |
| b | any | |
edgeMidpoint(a: any, b: any) → Vec
| arg | type | description |
|---|
| a | any | |
| b | any | |
_groundNode(ix: number, iz: number) → number
| arg | type | description |
|---|
| ix | number | |
| iz | number | |
_gridView(r: number, ew: number) → any
| arg | type | description |
|---|
| r | number | |
| ew | number | |
walkable(ix: number, _iy: number, iz: number) → void
| arg | type | description |
|---|
| ix | number | |
| _iy | number | |
| iz | number | |
position(node: any) → Vec
| arg | type | description |
|---|
| node | any | |
adjacent(node: any) → void
| arg | type | description |
|---|
| node | any | |
edgeMidpoint(a: any, b: any) → Vec
| arg | type | description |
|---|
| a | any | |
| b | any | |
_buildWaypoints( ) → void
Waypoint network: points `spacing` apart on every floor, each moved to the
roomiest spot near its lattice point, joined to nearby points when a
straight walk between them is clear.
_waypointView(r: number) → any
| arg | type | description |
|---|
| r | number | |
adjacent(node: any) → void
| arg | type | description |
|---|
| node | any | |
findPath(from: any, to: any, profile: Profile?) → PathResult
| arg | type | description |
|---|
| from | any | |
| to | any | |
| profile | Profile? | |
smooth(points: { PathPoint }, radius: number?) → void
String-pull a path: drop every corner a straight, clear walk can skip.
Link points (ladders, jumps, …) are kept exactly.
| arg | type | description |
|---|
| points | { PathPoint } | |
| radius | number? | |
info( ) → any
Summary for tools and the debug view.