Prevent RecastGraph from merging navmesh polygons across clearance / height thresholds (during generation)

  • A* version: 5.4.5 Pro
  • Unity version: 6000.3.1f1

Hi,

I’m working on an RTS-style game in Unity using A* Pathfinding Project Pro with a RecastGraph. I have a traversal system where agents can automatically switch posture (stand / crouch / prone), and traversal legality (and cost) depends on vertical clearance rather than simple walkability.

Recast’s region merging + contour tracing + polygonization simplifies large, flat areas into single convex polygons. This works great for normal pathfinding, but it destroys information I need later: A single large polygon may contain areas with different vertical clearances. Example: part of a room allows standing (clearance ≥ 1.9m), part only allows crouching (clearance ≈ 1.2m). After polygonization, this entire area becomes one node, and I can no longer distinguish the clearance bands reliably. I don’t want to use separate navmeshes per stance because I might have many types of agents with many types of stances.

I already tag nodes after generation based on clearance but this merging is the thing that causes issues. I don’t think GraphModifier has a hook in the middle of generation before polygon merging because OnPostScan() is after the whole graph is built. Is there a way I could hook in during generation and stop the merging of nodes across multiple height difference thresholds so that the agent can still traverse across those height differences but that the mesh stays complex enough so that I can tag it with the appropriate tag for walk-ability cost? Thanks for the help!