I am trying to change my enemy target when the enemy enter on trigger. Enemy has NavMeshAgent attached. In trigger I have code below. However it always displays on console “NavMeshAgent not found”. Could you please tell me what is the problem.
var nextTarget:Transform;
function OnTriggerEnter (other : Collider) {
if (other.GetComponent(NavMeshAgent) != null) {
other.GetComponent(NavMeshAgent).destination = nextTarget.position;
}
else {
Debug.Log("NavMeshAgent not found");
}
}