NavMeshAgent myAgent = GetComponent(); myAgent.Stop();
NavMeshAgent[] allAgents = FindObjectsOfType(); foreach (NavMeshAgent curAgent in allAgents) { curAgent.Stop(); }
GameObject targetObject = GameObject.Find("Target"); NavMeshAgent myAgent = GetComponentThis code sets a NavMeshAgent's destination to a game object named "Target" and stops it when it gets within 5 units of that object. Overall, the NavMeshAgent Stop method is a useful tool for controlling the navigation of game objects in Unity.(); myAgent.SetDestination(targetObject.transform.position); if (Vector3.Distance(transform.position, targetObject.transform.position) < 5f) { myAgent.Stop(); }