Search Unity

Navmesh paths

Discussion in 'Scripting' started by Brenden-Frank, Apr 20, 2014.

  1. Brenden-Frank

    Brenden-Frank

    Joined:
    Aug 5, 2012
    Posts:
    110
    Hey guys, just looking for some clarification on navmeshes. Does the agent calculate its path using the vertices on the edges? It seems I only ever get paths that run along the walls and edges. If anyone has found a way to make the path more centered on a navmesh I'd love to hear it.

    My current direction is to make the minimum width high enough that the navmesh doesn't go very close to the walls but of course narrow passageways lose their generated path and I have to rely on offmeshlinks.

    Is this the best solution to getting paths that don't run along walls and corners bumping into everything? Seems less than ideal, at least with a point graph I can center nodes and get a more reasonable and realistic movement.
     
  2. jschieck

    jschieck

    Joined:
    Nov 10, 2010
    Posts:
    429
    I'm not sure if there is a built in parameter for it, but you could easily use NavMesh.FindClosestEdge to get the nearby edge and offset by the hit normal. Or probably a faster method, on the NavMeshAgent.path your have the corners Vector3[] and could use those to get the normal vector of the wall and cross product that to get the normal and offset your object using that vector