Search Unity

Resolved Obstacle avoidance causing agents to slow down on corners

Discussion in 'Navigation' started by Jimbo_93, Mar 13, 2021.

  1. Jimbo_93

    Jimbo_93

    Joined:
    Mar 2, 2021
    Posts:
    7
    I'm having a problem where the NavMeshAgent will really slow down when going around corners on the nav mesh.

    It seems obstacle avoidance is causing this.. and I honestly can't see why, or find any setting to make it better besides disabling avoidance all together.

    Has anyone else played around with this?
     
    Last edited: Mar 13, 2021
    bluemanD and sinedsem like this.
  2. Jimbo_93

    Jimbo_93

    Joined:
    Mar 2, 2021
    Posts:
    7
    Okay it seems the problem is not really corners themselves, but instead when the agent turns around a corner onto a thin navmesh strip. Doorways are very common for this if the agent is approaching the door at a steep angle.

    Obstacle avoidance is not looking ahead on the agents path, but instead in the agents direction of travel. As the agent approaches corners like mentioned above, avoidance predicts that the agent is about to wonder off the navmesh, which triggers the agent to slow down.

    Even if you have your agent configured so that it could make the turn at full speed without leaving the navmesh, this has no impact on what local avoidance predicts.

    I'm not really seeing a solution to configure this behaviour. Looks like I might be up for writing my own path traversal / local avoidance :(
     
    bluemanD likes this.
  3. Jimbo_93

    Jimbo_93

    Joined:
    Mar 2, 2021
    Posts:
    7
    UPDATE:

    I have something of a solution which allows me to keep using Unity's NavMeshAgent / Obstacle avoidance!

    The easiest method for my project was to create my own avoidance detection system, which activates NavMeshAgent's local avoidance when it's actually needed.

    Each agent looks ahead on their path at a distance of two times their radius. Then each agent checks if their projected points will be within colliding distance. If they predict a collision, then obstacle avoidance changes from "none" to "high quality".

    This allows them to keep navigating around each other fluently, and still maintain full speed on corners.

    You could have them look further ahead on their path if you want earlier reaction time, but you have to do it in intervals of their radius*2 along their path, or they could fail to predict a collision.