title: Unity Fix NavMeshAgent Auto Rotate 90 degrees
body: <p>I am currently using a Taxi model from as an enemy with AI that will drive to different waypoints. Whenever the car moves to a waypoint it auto rotates 90 degrees to the right, right away but keeps moving from waypoint to waypoint.</p>
  
  <p>How do I fix a NavMeshAgent that auto turns 90 degrees when moving to a waypoint? The commented out code fixes the auto rotate but does not rotate enough when moving to the waypoint upon setDestination.</p>
  
  <p>The uncommented code first rotates 90 degrees and then rotates a little after each waypoint (from the 90 degree position).  (Unity API script from Vector3.RotateTowards)</p>
  
  <p>_agent.UpdateRotation = false , stops initial rotation but I then have to control rotation manually (which I am having a hard time with)  </p>
  
  <h2><img src="https://i.stack.imgur.com/slr58.png" alt="screenshot"></h2>
  
  <pre><code> private void Start()
      {
          _agent = GetComponent&lt;NavMeshAgent&gt;();
           // Almost works doesn't rotate enough
          //_agent.updateRotation = false;
          _isStopped = false;
      }
  
      private void Update()
      {
          //Almost works, doesn't rotate enough
          //transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, (_angleToRotate) * 8, 0), 1f);
  
          //Rotates but turns 90 degrees first
          Vector3 targetDirection = _wayPoints[_currentWayPoint].transform.position - transform.position;
          float singleStep = _speed * Time.deltaTime;
          Vector3 newDirection = Vector3.RotateTowards(transform.forward, targetDirection, singleStep, 0.0f);
          Debug.DrawRay(transform.position, newDirection, Color.red);
          transform.rotation = Quaternion.LookRotation(newDirection);
  
          switch (_currentState)
          {
              case AIState.NonAlert:
                  //Debug.Log("Not Alert...");
  
                  if (_isStopped == true)
                  {
                      return;
                  }
                  else
                  {
                      if (_wayPoints.Count &gt; 0)
                      {
                          _agent.SetDestination(_wayPoints[_currentWayPoint].transform.position);
  
                          //Gets distance between two Vector3s
                          float distanceToWayPoint = Vector3.Distance(_wayPoints[_currentWayPoint].transform.position, transform.position);
  
                          if (distanceToWayPoint &lt; 1.0f)
                          {
                              _currentWayPoint++;
  
                              //Almost works, doesnt rotate enough
                              //_angleToRotate = Vector3.SignedAngle(transform.position, _wayPoints[_currentWayPoint].transform.position, Vector3.up);
                          }
                      }
                  }
  </code></pre>
  
  <hr>