Unreachable paths + NavmeshCut = don't detect path can't be reached

When my unit sets a destination that it cannot reach because it’s OFF the navmesh, it goes towards the point that’s closest.

However if it’s a point that is ON the NavMesh but that has been cut out due to a NavmeshCut component obstructing the path, it won’t understand that it cannot go to its destination.

The following code should return true whenever the unit can no longer walk the path because it has reached the closest destination that it can reach. Is there a way to make it include the case where a NavmeshCut obstructs the path to the destination?

    protected bool AiIsArrivedToDestination(float? _stopDistance = null)
        // Check if we've reached the destination
        if (!ai.pathPending && ai.hasPath)
            float baseDist = 0f;
            if (richAi != null)
                baseDist = richAi.endReachedDistance;
            else if (pathAi != null)
                baseDist = pathAi.endReachedDistance;
            var stopDist = _stopDistance ?? baseDist;
            if (ai.remainingDistance <= stopDist || ai.reachedEndOfPath || ai.reachedDestination)
                return true;

        return false;


A navmesh cut is identical to a normal obstacle from the pathfinding subsystem’s point of view. ai.remainingDistance should go to zero when it reaches the end of the path. ai.reachedEndOfPath should also return true… Can you try to log ai.remainingDistance when the agent is supposed to have reached the end of the path?

I’m not sure I understand what you mean by “reached the end of the path” seeing as in reality it never reaches the end of the path. The unit has its path blocked and cannot go to the destination.

I assume you mean when it’s being blocked and cannot move along the path anymore.
It usually is a small value of remaining distance, for example: .345f

I went up to .5f in endReachedDistance and the issue did occur still in some cases.

The spider is moving towards the destination (blue circle) but is blocked by the door’s NavmeshCut component. You can see the remaining distance in the inspector of the Spider_AI called REMAINING_DISTANCE.


I notice your agent has canMove disabled. Why is this? Are you setting that dynamically?

If the agent cannot reach the destination it will calculate a path to the closest point it can reach. Therefore even though it may not reach the destination it will reach the end of the path eventually.

It has canMove disabled due to my using a custom controller.

In order to test it more accurately I have re-enabled the canMove and removed my custom controller on the creature leaving with a simple collider and a rigidbody. However the issue occured again.

I think my settings are quite standard but just in case I will paste them here.
I also have a Seeker component with the standard values.

I am on the latest version available on the asset store of AStar Pathfinding, I am using Unity 2019.2.16

Ah the mistake I made was that the NavmeshCut component’s bounds were slightly too small!

Sorry about all this, everything’s in order on your end :slight_smile: