What would cause result from Calculate Path to differ from SetDestination

My AI use NavMeshAgent.CalcuatePath. However, I have a reproducible case where the method returns an invalid path (returning false), despite no obvious reason - i.e. looking at the NavMesh a simple valid path was available.

If I use NavMeshAgent.SetDestination in the same place, a valid path is found. Specifically:

        NavPath = new NavMeshPath();
        bool result = agent.CalculatePath(destination, NavPath);
        bool result2 = agent.SetDestination(destination);

Reliably at one point, when the code runs, result = true but result2 = false. (In the same FixedUpate frame) What could cause this? Does CalculatePath have different constraints or assumptions, or is it a bug in Unity?

Well… I have solved my problem… …but it doesn’t quite explain the discrepancy here.

Both CalculatePath and SetDestination were in fact failing to create a complete path.

  • CalculatePath returned a path with 0 corners, status invalid, method result false.
  • SetDestination returned a path with 1 corner (the starting position!), status complete (wrong!) and method result true (also misleading).

The reason I was failing to get a (genuinely) complete path is my destination was below the surface of the navmesh! Ooops.

It seems that the paths / logic resulting from SetDestination and CalculatePath aren’t identical - although the difference, in my case, was ultimately of practical significance.