Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

NavMeshAgent with Collider as Trigger call OnEnter/OnExit endlessly

Discussion in 'Navigation' started by Ramazoid, May 11, 2015.

  1. Ramazoid

    Ramazoid

    Joined:
    Mar 11, 2014
    Posts:
    8
    Hero have NavMeshAgent component and capsule collider as trigger. On collide with someones collider (as trigger too) there is invokes both OnTriggerEnter and OnTriggerExit event on Hero on both colliders. Start calls, call every frame, and ends when colliders stop intersect.

    Rigidbody on Hero. Have or not Rigidbody on collided thing - not matter.

    Without NavMesh everything is ok.

    Is there a way to solve problem, or I have to give up NavMeshAgent?
     
    uygaruncosoft likes this.
  2. Chromophone

    Chromophone

    Joined:
    May 31, 2015
    Posts:
    1
    I'm experiencing the same issue. Did you manage to solve it or does anyone know why this keeps triggering endlessly?

    Thanks in advance!
     
  3. McMayhem

    McMayhem

    Joined:
    Aug 24, 2011
    Posts:
    443
    I wouldn't throw the NavMeshAgent away just yet. There are still a few steps you can try to debug this situation.

    I assume you are running some kind of check inside the OnTriggerEnter() thread to make sure the object it's colliding with is the right one for whatever it's doing.

    What you want to do now is find out what object is causing the continuous call. Try adding this to your OnTriggerEnter() code:
    Code (CSharp):
    1. void OnTriggerEnter(Collider other)
    2. {
    3.      //Put this above all the other code so that you know it's getting called correctly.
    4.  
    5.      Debug.Log(other.gameObject.name);
    6.  
    7. }
    That should at least let you know what it's colliding with.