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
Properties
Section titled “Properties”| 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.
Lua methods
Section titled “Lua methods”Call them on the node (self.node in its script, or self.node:get_node("path")). Every node also has the Node methods.
NavigationRegionNode:get_property(path)
Section titled “NavigationRegionNode:get_property(path)”Reads an Inspector property by its path (vectors and colours as tables); “script.
local value = self.node:get_property("size")pathNavigationRegionNodeProperty|string
Returns any
NavigationRegionNode:set_property(path, value, y)
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.
self.node:set_property("size", 100, 50)pathNavigationRegionNodeProperty|stringvalueanyy?number
NavigationRegionNode:nav_rebake()
Section titled “NavigationRegionNode:nav_rebake()”Rebuilds the region’s cells from the scene (after moving walls, loading a level, painting tiles).
Scene.find_node("NavigationRegion"):nav_rebake()NavigationRegionNode:nav_set_blocked(x, y, w, h, blocked)
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)xnumberynumberwnumberhnumberblocked?booleanDefault true
In a scene file
Section titled “In a scene file”{ "type": "NavigationRegionNode", "name": "NavigationRegion", "position": [ 0, 0 ], "properties": { "size": [ 1280, 720 ], "cellSize": 16, "usePhysics": true }}