Search Unity

NavMesh.CalculatePath returns a complete path which is not on a NavMesh

Discussion in 'Navigation' started by Gru, Feb 4, 2020.

  1. Gru

    Gru

    Joined:
    Dec 23, 2012
    Posts:
    142
    Using Unity 2017.4.36f1.

    After building the navmesh at runtime, I have a feature where I pick a position on the navmesh. To verify the picked random position is on the mesh I use something like:

    Code (CSharp):
    1. var isPathOK = NavMesh.CalculatePath(safeInitializationSpot.position, pickedPosition, NavMesh.AllAreas, _pathTemp);
    2. if (isPathOK && _pathTemp.status == NavMeshPathStatus.PathComplete) {...}
    This code passes for spots which are obviously not on the navmesh:
    upload_2020-2-4_13-14-34.png

    This is either:
    a) A bug in NavMesh
    b) It is considered that path is full if it is within radius of the agent even when not on the path. This is not what documentation claims: https://docs.unity3d.com/ScriptReference/AI.NavMeshPathStatus.html

    Which one is it?