I am new to Unity5. I am facing following error while trying to do setDestination.
"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)
Please find below my code for your reference.
public class MyEnemyMovement : MyMonoBehaviour
void Awake ()
players = GameObject.FindGameObjectWithTag ("Player").transform;
playerHealths = players.GetComponent <PlayerHealth> ();
enemyHealths = GetComponent <EnemyHealth> ();
navs = GetComponent <NavMeshAgent> ();
void Update ()
if(enemyHealths.currentHealths > 0 && playerHealths.currentHealths > 0)
navs.enabled = false;
May I know what is wrong with the above code? Does anyone have any solution on my issue?