Search Unity

Question Some Navmesh Agents ignore destination and just walk forward

Discussion in 'Navigation' started by Kennosuke, Jun 25, 2021.

  1. Kennosuke

    Kennosuke

    Joined:
    Jun 29, 2018
    Posts:
    16
    Has anyone ever encountered an issue where 99% of your NavMesh agents work fine, but occasionally you encounter 1 that doesn't path find and just walks straight forward?

    I've confirmed that the agent has a proper destination, but it just seems to be ignoring it.

    I haven't found any information other than one of Brackey's videos showing any kind of a hard limit to NavMesh agents. Even so, I have fewer than 40 agents active in a scene at any point in time.

    I am not receiving any errors, and all the other logic on the affected entities appears to be working as expected, too.

    The entities are instantiated from prefabs, so there should not be any difference between them.

    I'm at a bit of a loss. Does anyone have any ideas or advice?
     
  2. Kennosuke

    Kennosuke

    Joined:
    Jun 29, 2018
    Posts:
    16
    A bit of new information to add to this odd issue.

    upload_2021-8-2_19-29-6.png

    I'm visually debugging the nav-path of my monsters with line renderers, and have witnessed that monsters that aren't pathing to my player are ignoring 1 of the 3 world axis. In this screen shot, you can see that the monster just to the bottom left of my player has the correct Z-axis target, but it has the wrong X-axis target. Y-axis is moot.

    In contrast, the monster on the top right is correctly navigating to the player.

    Both are targeting the player's body collider GameObject's transform.position as their destination.

    I just can't seem to figure out why very rarely a monster ignores the X or Z axis, thus causing the monster to not properly engage the player.

    For now, I'm going to perform a distance check of the NavMesh Agent's final waypoint in comparison to the player's body collider position. If it is too far, I'll null the destination target and re-initialize it. I'll update this post if I confirm the solution works or not
     
  3. Kennosuke

    Kennosuke

    Joined:
    Jun 29, 2018
    Posts:
    16
    Hmmm, so even setting the destination target to "null" and then re-initializing the target position on the next frame doesn't fix the odd NavMesh Agent behavior.

    I've confirmed that the NavMesh has no holes or disconnects.

    What's further odd is that the line renderer confirms there are positions the agent is supposed to walk towards (even if the end point is wrong), but the agent is ignoring those, too.

    upload_2021-9-15_15-51-2.png

    In this image, the end point for the agent is south-west from the monster's current position, but you can see the monster is heading directly west into the wall (represented by the z-axis arrow in blue).

    Agents that are affected by the problem seem to have no obstacle avoidance, only 1 way-point in their navigation (i.e. no corners), and ignore even that 1 end way-point.

    Enabling and disabling "Auto Repath" has no effect.

    Enabling/disabling root motion on the Animator has no effect.

    Different Update Modes on the animator has no effect, though "unscaled time" did teleport the monster far off the map.

    Different Culling Modes on the animator has no effect.

    Changing the obstacle avoidance quality on the agent has no effect.

    Changing the area mask layer on the agent to "everything" has no effect.

    There are no Off Mesh Links in my scene.

    What FINALLY fixed the affected monster is disabling the NavMesh Agent component, and then re-enabling it.

    I should specify that I am on Unity 2018.4.23f1.

    Of course, I can code the agents to disable and re-enable themselves every so often, but I would much rather learn what is causing the problem to begin with so I can avoid it all together.

    Anyone have any ideas?
     
    Last edited: Sep 16, 2021