I want to navigate from one area to another that is disconnected. Is there a way to find the closest points between these two disconnected areas to dynamically create a NodeLink2 for cross-region movement?
I am using FollowEntity and RecastGraph.
The only way I can think of making this happen is to first find the closest node on the destination graph that is the closest to the destination’s position. (More information on GetNearest
here).
GraphNode closestDestinationNode = destinationGraph.GetNearest(destinationPosition, null, Mathf.Infinity).node;
From that node’s position, find the nearest node on the current graph:
GraphNode closestCurrentGraphNode = currentGraph.GetNearest((vector3)closestDestinationNode.position, null, Mathf.Infinity).node;
That’ll give you two positions you can make your Node Link with- two nodes, even. For traversing between two complex graphs though, that could be more difficult.
Is there a specific reason you want the green area to not be a part of the first graph?
Thank you very much for your suggestion. I ended up trying to use GetNearest to connect the two disconnected regions, and it worked perfectly.
Glad to hear! Thanks for reporting back