title: Unity - "SetDestination" can only be called on an active agent that has been placed on a NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3)
body: <p>I'm using Unity5 right now. I got this error when try to setDestination.</p>
  
  <blockquote>
    <p>"SetDestination" can only be called on an active agent that has been placed on a NavMesh.
        UnityEngine.NavMeshAgent:SetDestination(Vector3)
        CompleteProject.EnemyMovement:Update() (at Assets/_CompletedAssets/Scripts/Enemy/EnemyMovement.cs:30)</p>
  </blockquote>
  
  <p>My code.</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  namespace CompleteProject
  {
      public class EnemyMovement : MonoBehaviour
      {
          Transform player;               // Reference to the player's position.
          PlayerHealth playerHealth;      // Reference to the player's health.
          EnemyHealth enemyHealth;        // Reference to this enemy's health.
          NavMeshAgent nav;               // Reference to the nav mesh agent.
  
  
          void Awake ()
          å{
              // Set up the references.
              player = GameObject.FindGameObjectWithTag ("Player").transform;
              playerHealth = player.GetComponent &lt;PlayerHealth&gt; ();
              enemyHealth = GetComponent &lt;EnemyHealth&gt; ();
              nav = GetComponent &lt;NavMeshAgent&gt; ();
          }
  
  
          void Update ()
          {
              // If the enemy and the player have health left...
              if(enemyHealth.currentHealth &gt; 0 &amp;&amp; playerHealth.currentHealth &gt; 0)
              {
                  // ... set the destination of the nav mesh agent to the player.
                  nav.SetDestination (player.position);
              }
              // Otherwise...
              else
              {
                  // ... disable the nav mesh agent.
                  nav.enabled = false;
              }
          }
      }
  }
  </code></pre>
  
  <p>Reference: <a href="https://github.com/datomnurdin/SurvivalShooter" rel="nofollow noreferrer">https://github.com/datomnurdin/SurvivalShooter</a></p>