Skip to content

Navigation Region

An area agents find paths in: baked into a grid from static bodies, solid tile maps and LDtk Solid cells. Bake in the Inspector; scripts can block cells (doors).

Type: NavigationRegionNode · Category: Physics & Collision · Also found as: navigation, nav region, navmesh, pathfinding

Property Type Default Description
size vec2 (1280, 720) The area agents find paths in, from the node’s position (px). Range 16 to 20000.
cellSize number 16 Size of a grid cell (px): smaller follows walls more closely, larger finds paths faster. Range 2 to 256.
usePhysics boolean true Static bodies’ collision shapes inside the area block.
useTileMaps boolean true Solid tile maps’ painted tiles block.
useLdtk boolean true LDtk IntGrid cells with a Solid collision rule block.

Plus the common properties every node has.

Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.

Reads an Inspector property by its path (vectors and colours as tables); “script.” reads a field of the node’s script.

local value = self.node:get_property("size")
  • path NavigationRegionNodeProperty|string

Returns any

Section titled “NavigationRegionNode:set_property(path, value, y)”

Sets an Inspector property by its path: vectors as {x, y} or x, y; colours as {r, g, b[, a]} 0..1 or “#rrggbb[aa]”; enums by name; “script.” a field of the node’s script.

self.node:set_property("size", 100, 50)
  • path NavigationRegionNodeProperty|string
  • value any
  • y? number

Rebuilds the region’s cells from the scene (after moving walls, loading a level, painting tiles).

Scene.find_node("NavigationRegion"):nav_rebake()
Section titled “NavigationRegionNode:nav_set_blocked(x, y, w, h, blocked)”

Blocks (or opens) a world rectangle for paths - doors, bridges, placed towers. Kept across rebakes.

region:nav_set_blocked(door.position.x - 16, door.position.y - 32, 32, 64, not self.open)
  • x number
  • y number
  • w number
  • h number
  • blocked? boolean Default true
{
"type": "NavigationRegionNode",
"name": "NavigationRegion",
"position": [
0,
0
],
"properties": {
"size": [
1280,
720
],
"cellSize": 16,
"usePhysics": true
}
}