Search Unity

NavMeshAgents act crazy at the NavMesh edges of the generated mesh.

Discussion in 'Navigation' started by Athomield3D, May 21, 2018.

  1. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    I keep getting this issue where NavMeshAgents go nuts when encoutering a NavMesh edge of the generated mesh (especially when the fps drops), it may even get stuck at the (0,0) point of the NavMesh, I've been having this issue for ages and I'm not sure if it's a bug or not.
     
  2. newjerseyrunner

    newjerseyrunner

    Joined:
    Jul 20, 2017
    Posts:
    966
    I've never seen this. How exactly are your agents getting to the edge of the navmesh?

    Sounds like you are setting the destination to somewhere it shouldn't be and I'll bet there are console errors.
     
    Athomield3D likes this.
  3. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    When I said edges I meant edges as in like (verticies/edges/faces) and not the border of the navmesh.
    What the characters do is they go in zig-zag motions and slow down, as if these edges are an obstacle somehow. Unfortunatley I was not unable to reporduce it now to show it in a gif.
    Does the hight of the navmesh destination matter ?

     
  4. newjerseyrunner

    newjerseyrunner

    Joined:
    Jul 20, 2017
    Posts:
    966
    Yes, the height of your destination matters. The destination must intersect the plane of the mesh. The easiest way to assure that you're placing a target on the mesh is to use NavMesh.SamplePosition.
     
    Athomield3D likes this.
  5. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    Unfortunately sampling the position still didn't work. My issue similar to this question.
    Also I forgot to say that this happens most when the Time.timeScale is increased.

    EDIT: I'm considering switchting to an A* alternative, hoping it delivers a similar kind of performance.
     
    Last edited: May 22, 2018
  6. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    According to the docs the collision avoidance takes into account nav mesh edges, maybe try to set the collision detection to none and see if it solves it?

    provided it doesn't make the game look weird
    if that's the case you could extend the nav mesh a bit and keep the RVO
     
  7. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    I think you meant setting the avoidance in the navmesh agent to None as I have no rigidbodies attached to any character. Also this still didn't resolve the issue. I believe it's a persistant bug that keeps appearing and with each new version the Unity team says it's been fixed but it's not.
     
  8. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Sorry my reply didn't help, but where did you thought I said rigidbodies?
     
    Athomield3D likes this.
  9. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    Collision avoidance, not collision detection.
     
    Athomield3D likes this.
  10. Athomield3D

    Athomield3D

    Joined:
    Aug 29, 2012
    Posts:
    193
    @SparrowNest thank you for your time, it's always nice to see people helping others :) And yes for some reason I read it as collision detection.