Skip to content

Exporting the navigation mesh

The navigation mesh is the game’s own: the walkable surface of the level - every yard, road, floor, stair and bridge - as polygons, the way the game’s own people walk it. With it an NPC actor sent somewhere (MoveActor) walks there around the walls instead of straight through them, an actor chasing a player goes around the corner after them, and a game mode can ask for a walk between two points (FindPath), whether one is reachable from the other (IsReachable), where the floor is - indoors, on a bridge, where the terrain says otherwise (GetNavmeshHeight) - and the nearest walkable spot to a point (NearestNavmeshPoint).

Without it the actors walk straight lines - the body stops at a wall and catches up when the line comes out - and the functions answer nil / false; HasNavmesh tells a mode which it is.

Run tools/KcdMp.ExportNavmesh.exe from the Windows server folder on a machine that has the game. It reads the mesh straight from the level’s own files - the game does not start, it takes a second per level - and writes the files into the server folder’s data/navmesh/.

KcdMp.ExportNavmesh [--level <name>|all] [--variant <n>] [--game <folder>] [--out <folder>]

All three levels by default; --level klaster does one. The game keeps a mesh for the level as the story leaves it - doors bricked up, a ruin cleared, a camp built - and the tool takes the state a fresh world starts in; --variant <n> picks another of the level’s states, for a server that stages one (-1 is the base mesh alone). The game is found through Steam or --game; --out writes elsewhere. --help prints the same.

The tool puts the files where the server reads them. For a server on Linux, copy them into its data folder under navmesh/, named after the level (klaster.knav), and point the configuration at them:

[validation]
navmesh = "data/navmesh/{level}.knav"

{level} is replaced by the level the server runs. The server log confirms the mesh at start (navmesh: ... tiles, ... polygons ...: the actors walk paths, FindPath is live) or says why it could not use it.

One mesh per level per game build: after a game update, export it again.