Check which graph the point is on and whether it is available

In my project, I have to switch different graphs, and sometimes a problem arises that after switching a graph, AIPath changes the correct path to an incorrect graph that cannot build the desired path.
I want to avoid such a problem and want to find out immediately which graph the point is on and whether it is on the graph at all.
Is there an API for this?


The figure shows 2 graphs, graph 1 is small and graph 2 is large. T is target point.
When I’m on a small graph, AIPath tries to reach Target Point out of graph, but it’s useless, I want to avoid this.

GetNearest gives a slightly different result

Thnx for help :nerd_face:

Hi

The easiest thing is to check which graph the closest node is on:

var graph = AstarPath.active.GetNearest(some position, NNConstraint.None).node.Graph;

If you have a graph, you can also check if a point is inside its bounding box:

var graph = AstarPath.active.data.gridGraph;
bool isInside = graph.IsInsideBounds(some position);
1 Like