When playing, if you move a NavMeshAgent with editor’s XYZ handles, it stays on the nav mesh.

I need to move an object to my cursor’s position, but have it constrain to the nav mesh in the same way.

If I do “transform.position = raycastHitPoint”, it takes it off the nav mesh. I tried using SetPosition with high speed/accel values, but it’s not a great way.

What about disabling the navmeshagent, then moving it using transform.position, then, then re-enabling the navmeshagent after the move is finished.

NavMeshHit navMeshHit;

if (NavMesh.SamplePosition(raycastHitPoint, out navMeshHit, 1, 1))
{
	navMeshAgent.Warp(navMeshHit.position);
}