Search Unity

Path jagged <solved>

Discussion in 'Navigation' started by calpolican, Mar 6, 2019.

  1. calpolican

    calpolican

    Joined:
    Feb 2, 2015
    Posts:
    425
    For some reason *sometimes* my nav agent's path gets jagged (see image).
    It gets jaggier and jaggier as it approaches the destination (the image shows the character's final position).
    The problem persists with the animator turned off.
    The object with the character has no rigidbody that could cause conflict.

    nav mesh path not always stright.jpg
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Huh, that DOES sound like another component interfering. Do you get the same issue with a minimal object (simple capsule with only the navmeshagent and the code used to drive the agent)?
     
    calpolican likes this.
  3. calpolican

    calpolican

    Joined:
    Feb 2, 2015
    Posts:
    425
    I have already tried that, and I didn't had any problem. Following your suggestion I tried to look more into it to see what could be interfering.
    Turns out I had an innecesarity NavObstacle component in my static obstacles. I realized that it only did the jagged motion when close to them, and then it was easy to figure out what was it.
    It seems that the jagged motion is something that the agent does whenever it aproaches any obstacle or agent to try to avoid it (I guess?). I hadn't been using the avoidance system and I don't know how it behaves so it took me by surprise.
    I can't believe I lost all day with such a silly thing. Thanks a lot for the help!