Skip to content

Navigation mesh

A pure-C# nav-mesh pathfinder that string-pulls the shortest taut path

This is a navigation-mesh pathfinder written in plain C# from the GameDevelopment.NavMesh leaf. It runs A* across a graph of convex cells, then a funnel - the simple stupid funnel algorithm - string-pulls the corridor, tightening it into a single taut path that hugs inner corners. The result is not the cell-centre zig-zag but the shortest polyline that stays inside the walkable mesh. Deterministic, analytic, and with zero dependencies on the .NET base library.

A*
cell search
funnel
string-pull
3
scenarios
0
NuGet packages
An L-shaped corridor of five convex cells with a blue start dot, a red goal dot, and a green taut path that bends once around the inner reflex corner
L corridor
Corner hug

Across an L of five cells the funnel collapses the route to a single bend that hugs the reflex inner corner - the shortest taut path, not the cell-centre zig-zag.

An open room with a solid block in the middle, a blue start dot and red goal dot, and a green path routing around the block pulled tight against its corner
Obstacle detour
Around the block

An open room with a solid block in the middle; A* routes around it and the funnel pulls the path tight against the obstacle's corner.

A maze of staggered walls with a blue start dot and red goal dot, and one continuous green taut path zig-zagging from start to goal
Maze corridor
Zig-zag

Staggered walls force a longer route; the string-pull still yields one continuous taut path from start to goal.

How the pathfinder works

The mesh is a set of convex cells joined by shared-edge portals; A* finds the sequence of cells, then the funnel algorithm walks the portal left/right vertices, tightening an apex so the final path is the shortest polyline that stays inside the walkable cells - bending only at inner corners. All analytic geometry in plain C# on the base library, fully deterministic.