title: Unity NavMeshAgent does not contain a defintion for setDestination
body: <p>I'm trying to make a script for an AI in Unity but I get this error:
  error CS1061: 'NavMeshAgent' does not contain a definition for 'setDestination' and no accessible extension method 'setDestination' accepting a first argument of type 'NavMeshAgent' could be found (are you missing a using directive or an assembly reference?)</p>
  <pre><code>    using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.AI;
  
  public class enemyAI : MonoBehaviour
  {
      public NavMeshAgent agent;
  
      public Transform player;
  
      public LayerMask whatIsGround, whatIsPlayer;
  
      // Patrolling
      public Vector3 walkPoint;
      bool walkPointSet;
      public float walkPointRange;
  
      // Attacking
      public float timeBetweenAttacks;
      bool alreadyAttacked;
  
      // States
      public float sightRange, attackRange;
      public bool playerInSightRange, playerInAttackRange;
  
      private void Awake() 
      {
          player = GameObject.Find(&quot;player&quot;).transform;
          agent = GetComponent&lt;NavMeshAgent&gt;();
      }
  
      private void Update() 
      {
          // Check for in sight range and in attack range
          playerInSightRange = Physics.CheckSphere(transform.position, sightRange,whatIsPlayer);
          playerInAttackRange = Physics.CheckSphere(transform.position, attackRange, whatIsPlayer);
  
          if (!playerInSightRange &amp;&amp; !playerInAttackRange) Patroling();
          if (playerInSightRange &amp;&amp; !playerInAttackRange) ChasePlayer();
          if (playerInSightRange &amp;&amp; playerInAttackRange) AttackPlayer();
      }
  
      private void Patroling() 
      {
          if (!walkPointSet) SearchWalkPoint();
  
          if (walkPointSet) 
          {
              agent.setDestination(walkPoint);
          }
  
          Vector3 distanceToWalkPoint = transform.position - walkPoint;
  
          if (distanceToWalkPoint.magnitude &lt; 1f) 
          {
              walkPointSet = false;
          }
      }
  
      private void SearchWalkPoint() 
      {
          // Calculate random point in range
          float randomZ = Random.Range(-walkPointRange, walkPointRange);
          float randomX = Random.Range(-walkPointRange, walkPointRange);
  
          walkPoint = new Vector3(transform.position.x + randomX, transform.position.y, transform.position.z + randomZ);
  
          if (Physics.Raycast(walkPoint, -transform.up, 2f, whatIsGround)) 
          {
              walkPointSet = true;
          }
      }
  
      private void ChasePlayer() 
      {
          agent.setDestination(player.position);
      }
  
      private void AttackPlayer() 
      {
          agent.setDestination(transform.position);
          transform.LookAt(player);
  
          if (!alreadyAttacked) 
          {
              //AttackCode here
              Debug.Log(&quot;Enemy is attacking!!!&quot;);
  
  
  
              alreadyAttacked = true;
              Invoke(nameof(ResetAttack), timeBetweenAttacks);
  
          }
      }
  
      private void ResetAttack() 
      {
          alreadyAttacked = false;
      }
  }
  
  I've gotten 3 errors for the 3 times I use .setDestination(), I don't know what I'm doing wrong...
  </code></pre>