Skip to content

FindPath

The corners of a walk between two points on the navigation mesh.

The route an NPC actor would take, string-pulled to its corners: the first is the start snapped to the mesh, the last the end. nil when either point is off the mesh (more than 2 m from it sideways or 4 m up or down - a wall, a roof, the air), when no way joins them, or without a navmesh. Positions in metres, the level’s world space. A path takes well under a millisecond across a village; a mode that asks every tick for every actor should not.

Every search is bounded. An end on a part of the mesh that no way leads to (a closed room, a ledge) answers nil at once; any other search that visits more than navmesh_search_nodes nodes or takes longer than navmesh_search_ms milliseconds stops and answers nil too (both in [validation], see the server’s configuration; 16384 nodes and 100 ms by default - a walk of several hundred metres through a town usually needs a few thousand). The server log names each such search with its two points. The same two points that ran out of budget answer nil at once for the next five seconds.

FindPath(x1, y1, z1, x2, y2, z2)
Parameter Type
x1 number the start
y1 number
z1 number
x2 number the end
y2 number
z2 number

table of {x=, y=, z=} corners, the start first; nil for no way

local path = FindPath(px, py, pz, gx, gy, gz)
if path then SendClientMessage(pid, COLOR_SERVER, #path .. " corners to the goal") end

IsReachable · MoveActor · GetNavmeshHeight · the The world - clock, weather, terrain, the navmesh, the geometry group of the index