Search Unity

Avoid edges of navmesh

Discussion in 'Navigation' started by Zante, Jul 12, 2019.

  1. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    I'm attempting to get my navmesh agent to stay away from edges in a bid to make the path finding smoother and allowing for space on turns.

    The attached image shows what I'm trying to achieve.

    I'm struggling to find an elegant way to approach this and before I go straight into the overengineering.

    Any thoughts would be welcome.

    The only way I can think to do this would be to use object avoidance for entities on the edge of the navmesh and set the agent radius to something high.
     

    Attached Files:

    Last edited: Jul 12, 2019
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    You could also just use regions to assign a higher cost to the edge areas. That way they're still accessible, but preferrably avoided.
     
  3. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    How would you dynamically identify the border of a NavMesh and apply an area modifier to it? Is there a built-in mechanism?
     
  4. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Not as far as I know, I'm afraid. That'll be manual work.
     
  5. Zante

    Zante

    Joined:
    Mar 29, 2008
    Posts:
    429
    Well, it would involve creating a separate mesh out of the area where two potential NavMeshes do not intersect. This is still, probably, more difficult than identifying slopes and placing navmesh obstacles on them, with a large radius. ;]

    I might give it a go though, thanks for the suggestion.