NavMeshAgent's desiredVelocity and .hasPath falsely returning 0 / false

The following code executes with no errors in my game. the agent correctly moves to the position set in SetDestination, but the log prints ‘false’ and the desired velocity is 0. Even worse, I have made NO changes since this was working. This is literally Unity 5 example project code with one line of debug inserted. Yes I have tried deleting that line not that it should make a difference.

it’s also not a random compilation error. it happens 100% of the time now. What can I do about something like this?

agent.SetDestination( m_ChosenNode.transform.position );
				
Debug.Log(agent.hasPath); 
			
character.Move(agent.desiredVelocity, false, false);

If you read the documentation about SetDestination, the path might take more than one frame to calculate, so you will get hasPath false in the first frame sometimes.

In order to know if the NavMeshAgent is either calculating a new path or in the middle of following that parth, you should check agent.pathPending and agent.remainingDistance!=0. hasPath didn’t work properly for me due to it needing more than 1 frame usually to be calculated. However pathPending is true when the NavMeshAgent is calculating a new path.

This is a bit overkill, but this work for me. I just wanted to know if the navmeshagent had stopped moving:

if(myNavMeshAgent.enabled && !myNavMeshAgent.hasPath && !myNavMeshAgent.pathPending && myNavMeshAgent.remainingDistance==0)
{
//Your code here
}