Access NavmeshEdges data to get an equivalent to Unitys FindClosestEdge?

Hi Aron, I’m aware similar questions have been asked before, but could never be resolved completely.

As you might be aware the inbuilt unity Navmesh comes with a functionality FindClosestEdge. This function can conveniently be used to detect e.g. walls etc that might be used for cover for characters or other things.

Now the A* Pathfinding Project does not have a direct equivalent yet, but going through the source code, I’v seen the edge data is actually being collected and used for e.g. desiredWallDistance.

Could this be used to write a similar function like the one mentioned?
Or what is the AstarPath.active.hierarchicalGraph.navmeshEdges about?

Hi

Indeed.
It’s not quite exposed to users in a friendly way yet. But what you can do is to get all edges within a bounding box:

var navmeshEdgeData = AstarPath.active.hierarchicalGraph.navmeshEdges.GetNavmeshEdgeData(out var readLock);
readLock.dependency.Complete();
var node = AstarPath.active.GetNearest(somePosition).node;
var edgeBuffer = new NativeList<float2>(Allocator.Temp);
navmeshEdgeData.GetEdgesInRange(node.HierarchicalNodeIndex, someBoundingBox, edgeBuffer, new NativeMovementPlane(quaternion.identity));

(note: I haven’t tested the above code myself)

Thanks sounds good, the thing is that hierarchicalGraph is internal only, so I can’t access it atm. Maybe this could be made accessible in a future update?

Right.
I’ll think about the best way to solve this.

1 Like