Search Unity

Navmesh.SamplePosition stuck on edge

Discussion in 'Navigation' started by Grhyll, Dec 11, 2017.

  1. Grhyll

    Grhyll

    Joined:
    Oct 15, 2012
    Posts:
    119
    I've seen this kind of issue mentionned multiple times, but could never find a workaround...
    I'm using the navmesh to sample the terrain and check if my destination is valid (no NavMeshAgent, just moving the transform), and in some cases if I sample a point near an edge, the result will always be stuck on that edge.

    I've attached a file where it's quite clear: the left sphere is the point I'm trying to sample, and the right sphere is the result I get. I have tried quite a lot: changing the maxDistance, using CalculatePath and checking the last corner, trying to sample all around (always getting the nearest point on the edge), and I'm starting to feel out of option beside entirely discarding the navmesh and just calculating my own paths however I can.

    I get the issue on Unity 2017.1.1f1 and 2017.2.0f3. I don't really know why some edges behave that way (100% for them around somes zones) and some others don't create any issue.


    Edit: Btw I've seen the error reports https://issuetracker.unity3d.com/is...ts-get-stuck-on-edges-of-the-navmesh-polygons and https://issuetracker.unity3d.com/is...ect-value-on-slope-near-navmesh-internal-edge (marked à fixed), but it also happens outside of slopes for me, and... well, it's not fixed.

    Edit 2: I've just tried to use NavMeshSurface (didn't know about it), and it seems to fix the issue (at least on the edge I was stuck)!
     

    Attached Files:

    Last edited: Dec 11, 2017
    muhammad_ali_safdar likes this.