Trouble with NavMesh.CalculatePath

I’m working on a game that uses grid based movement.

I’m using Unity’s built in pathfinding to determine my paths, then using the resulting path to determine where to move my enemies.

I’m simply using some permutation of

    NavMesh.CalculatePath(transform.position, patrolPoints[currentPatrolPoint], 
                          NavMesh.AllAreas, path);

without a NavMeshAgent attached to my enemies

However, it’s become apparent that CalculatePath doesn’t seem to work immediately, and that it may take a few frames for the path to be calculated at all.

This is a problem, since I am using the validity of the path as a determining factor in my enemies’ AI, as to whether or not they should move, and I’m calculating the path and then immediately checking some conditions on said path.

My current plan is to wrap CalculatePath in a coroutine that first checks its validity before allowing the enemy to continue its own execution, but this seems like a clunky and imperfect solution, especially given that there is no way to tell (as far as I can find) whether or not the path has finished calculating.

The closest thing I can see in that regard is NavMeshPath.status–but that only holds information about the actual path itself (Partial, Complete, Invalid)–not about the status of the calculation being completed.

Any ideas?

Thanks!

So, after more investigation, it appears that it wasn’t a delay in the path being calculated, but the fact that my enemy had an attached NavMeshObstacle attached, which was preventing the path from being appropriately calculated.