---
title: "Handle a partial navmesh path in C#"
url: https://recursiveai.org/onepath/cookbook/handle-partial-navmesh-paths/
description: "Handle a partial navmesh path in C# with OnePath. Check IsPartial, stop at the last returned waypoint, and keep the requested goal marked as unreached."
version: "1.2.0"
---

# Handle a partial navmesh path in C#

**OnePath** is a free, open-source pathfinding library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OnePath) · [GitHub](https://github.com/recursive-ai-oss/onepath-csharp) · [Docs](https://recursiveai.org/onepath/docs/) · [Download example (.zip)](https://recursiveai.org/onepath/cookbook/handle-partial-navmesh-paths/handle-partial-navmesh-paths.zip)

If `IsPartial` is true, stop at the last waypoint instead of marking the goal reached.

```shell
dotnet add package RecursiveAI.OnePath
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
// Use the query and inputs below.
var path = query.FindPath(
    start, goal, options);
if (path.IsPartial && path.Points.Count > 0)
    Console.WriteLine(path.Points[^1].Position);
```

[The example](https://recursiveai.org/onepath/cookbook/handle-partial-navmesh-paths/handle-partial-navmesh-paths.zip) is the full program below: unzip it and `dotnet run`.

The last waypoint is `(2, 0, 1)`, not the requested destination.

## The full program

The example builds three adjoining squares. It starts at `(1, 0, 1)` in the first square and asks for `(5, 0, 1)` in the last one. The filter excludes the middle square (flag `2`), so the end square exists but can’t be reached.

```csharp
using RecursiveAI.OneMath;
using RecursiveAI.OnePath;
using RecursiveAI.OnePath.Mesh;
using RecursiveAI.OnePath.Mesh.Queries;

var query = MakeCorridor();
var start = new Vector3D(1, 0, 1);
var goal = new Vector3D(5, 0, 1);
var options = new PathOptions
{
    Filter = new QueryFilter { ExcludeFlags = 2 }
};
var path = query.FindPath(start, goal, options);
Console.WriteLine(path.Status);
if (path.IsPartial && path.Points.Count > 0)
{
    var stop = path.Points[^1].Position;
    Console.WriteLine(FormattableString.Invariant(
        $"Stop at ({stop.X}, {stop.Y}, {stop.Z}); goal not reached."));
}

static NavMeshQuery MakeCorridor()
{
    var settings = new NavMeshParams
    {
        TileSize = 8, CellSize = 0.25,
        MaxVertsPerPoly = 6, WalkableClimb = 0.5f
    };
    double[] vertices =
    [
        0, 0, 0,  2, 0, 0,  4, 0, 0,  6, 0, 0,
        0, 0, 2,  2, 0, 2,  4, 0, 2,  6, 0, 2
    ];
    var tile = NavTileAssembler.FromPolygons(settings, 0, 0, 0, 0,
        vertices, [4, 4, 4], [0, 1, 5, 4, 1, 2, 6, 5, 2, 3, 7, 6],
        [0, 0, 0], // Area IDs
        [1, 2, 1]); // Polygon flags
    var mesh = new TiledNavMesh(settings);
    mesh.AddTile(NavTile.Create(tile, settings));
    return new NavMeshQuery(mesh);
}
```

```text
Partial
Stop at (2, 0, 1); goal not reached.
```

If the query can’t find an allowed polygon near the start or goal, it reports `StartInvalid` or `GoalInvalid` instead of returning this best-effort path.

## Variations

Let the character cross the middle square by removing the filter. In the example, the status changes to `Found`:

```csharp
var open = query.FindPath(start, goal);
Console.WriteLine(open.Status);
```

## Related recipes

- [Filter navmesh areas and traversal costs](https://recursiveai.org/onepath/cookbook/filter-navmesh-areas-and-costs/)
- [Find navmesh path corners](https://recursiveai.org/onepath/cookbook/find-navmesh-straight-path-corners/)

## The short answer

Check `IsPartial` on the `PathResult` from `NavMeshQuery.FindPath`. If it’s true and you have waypoints, follow them and stop at the last one without marking the requested goal as reached. If your character must arrive at the goal or not move at all, accept only `Found`. `HasPath` is true for both `Found` and `Partial`; it’s not an arrival check.

## Why does a navmesh query return a partial path?

A valid start and a valid goal don’t guarantee there’s a connection between them. OnePath first looks for an allowed polygon near each position. If both exist, the search tries to connect them. An excluded area, as in the example, can break that connection. Reaching the search’s node limit can also produce a partial result, so `Partial` alone doesn’t tell you which cause applies. Check the filter and the query settings before deciding whether the underlying map needs to change.

A partial result differs from an invalid goal. In this example the goal polygon is allowed and nearby, but the middle polygon can’t be crossed. If the query can’t find an allowed polygon near the requested destination in the first place, it gives `GoalInvalid`. In that case there is no partial route to follow. The same distinction applies to `StartInvalid` at the other end.

## Where does a partial navmesh path end?

OnePath uses the last polygon of the partial corridor, meaning the last area of walkable surface in the route it found. It projects the snapped goal onto that polygon and runs the straight-path query toward that point. The example reaches the edge of the first square at X = 2; walking in a straight line from there to X = 5 would cross the forbidden square.

Use `Points` for world-space movement and `Corridor` when you need polygon references. Keep the goal separate from the waypoint list so that reaching the last point never silently turns a partial route into success. Check that points exist before indexing, and check the result’s truncation flags if you set a small corridor or point limit. A returned waypoint at the end of a truncated list need not be the end of the route the search found.
