IsPathPossible return true to target out of graph

Hi, I’m having problem with IsPathPossible API

it returns true even when the target is outside the graph.


with Checking if the path reachable.

here’s the code

public Transform target;
public Seeker seeker;
public List<Vector3> paths = new List<Vector3>();
public GraphNode nodeA;
public GraphNode nodeB;

[ContextMenu("Find Path")]
public void OnUpdatePath()
{
    StartCoroutine(nameof(FindPathEnumerator));
}

[ContextMenu("Check Path")]
public void CheckPath()
{
    nodeA = AstarPath.active.GetNearest(transform.position).node;
    nodeB = AstarPath.active.GetNearest(target.position).node;

    Debug.LogError($"Is Path Possible : {PathUtilities.IsPathPossible(nodeA, nodeB)}");
}

also when I’m doing this

Debug.LogError($“Is Path to {(Vector3)nodeB.position} Possible : {PathUtilities.IsPathPossible(nodeA, nodeB)}”);

it seems like the target node position is not in the latest point of path

Hi

You are first getting the closest node to your position, and then checking if there’s a path between them. The closest node is always on the graph by definition.

You can check if GetNearest(query).position is further away from query than some threshold, and in that case return false.