DEV Community

Cover image for Why Your Unity NavMesh Agent Won't Cross That Gap
Muhammad Talha Malik (Malik)
Muhammad Talha Malik (Malik)

Posted on

Why Your Unity NavMesh Agent Won't Cross That Gap

Baked NavMesh only connects walkable surfaces that physically touch each other. The moment there's a gap, a drop to a lower platform, or a ledge, agents treat the edge as a wall and simply stop, even when the crossing is obviously possible from a design standpoint.

Off-Mesh Links solve this. You place one link point on each side of the gap and connect them:

csharp
// Runtime example: check if an agent is currently on an off-mesh link
if (agent.isOnOffMeshLink)
{
OffMeshLinkData data = agent.currentOffMeshLinkData;
// trigger a jump/climb animation, then call agent.CompleteOffMeshLink()
}

Once connected, the NavMesh treats that gap as traversable, and you control what actually happens when the agent crosses it, a jump animation, a drop, a climb, whatever fits the movement.

Easy to overlook because the NavMesh bake still succeeds without them, it just quietly excludes any area that needs one. If your AI is avoiding a route that should obviously work, this is usually why.

Top comments (0)