- Home /
Problem accessing NavMeshAgent
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"); } }
Answer by GoffardGafgarion · Sep 22, 2013 at 06:18 AM
I'm not as skilled as i'd like to, but my little experience with navmesh says to use SetDestination() instead of setting the destination via destination variable.
Answer by Sobakaduka · Feb 26, 2016 at 12:14 PM
That can only mean, that the object that enters the trigger doesn't have NavMeshAgent attached.