Navmesh Agent skips every other destination

I call GotoPoint() from another script when it’s time to send an NPC using Navmesh Agent component to a new destination. Effectively when they reach the destination they stop and wait for another command at a later point.
The problem is the NPC only goes on every other call to GotoPoint(). Any idea why it’s skipping like this?

internal void GotoPoint(Vector3 dest) 
{
		paused=false;
		animator.SetBool ("paused",paused);
		agent.destination = dest;
		agent.Resume ();    
	}	
	
	void Update () 
	{
		if (agent.remainingDistance <= .5 && !paused)
		{     
			paused = true;
			animator.SetBool ("paused",paused);    
			agent.Stop();
		}
	}

Note: if I add “agent.destination = Vector3.zero;” just after agent.Stop() it seems to then work as expected. But I’d like to know why this is needed.

i thought of that, it just seems incredible that it’d do so so consistently, if its running as a parallel thread what are the odds?

so here’s a possibility based on looking at

navmeshagent.destination docs.

If a destination is set but the path is not yet processed the position returned will be valid navmesh position that’s closest to the previously set position.

the thing is remaining distance seems like it uses the return value of destination to determine remaining distance and it explicitely says it returns a really close point if the path is being processed.

perhaps its returning a really close destination for remainingdistance while it tries to calculate the ideal path.

using the bool pathpending to check for that according to the docs.

so in update do the whole distance < !paused && !agent.pathpending

the agent.pathpending shoudl fix it maybe?