Couldn't find a close node to the end point

I use A* Pathfinding, and follow the example drag AstarPath.cs to A* sprite, seeker.cs to my player, but it cant work. The console print:“Couldn’t find a close node to the end point”. I debug the code:

	if (!constraint.Suitable(nearestNode.node) || (constraint.constrainDistance && (nearestNode.clampedPosition - position).sqrMagnitude > maxNearestNodeDistanceSqr)) {
		return new NNInfo();
	}

line from 1948 to 1950 in AstarPath.cs, this return node of NNInfo is null, so

var endNNInfo = AstarPath.active.GetNearest(endPoint, nnConstraint);
endPoint = endNNInfo.position;
endNode = endNNInfo.node;

			if (startNode == null && endNode == null) {
				Error();
				LogError("Couldn't find close nodes to the start point or the end point");
				return;
			}

			if (endNode == null) {
				Error();
				LogError("Couldn't find a close node to the end point");
				return;
			}

(line from 345 to 358 in ABPath.cs)
the endNode is null…

how can I fix it?

I change the code:

	if (!constraint.Suitable (nearestNode.node) || (constraint.constrainDistance && (nearestNode.clampedPosition - position).sqrMagnitude > maxNearestNodeDistanceSqr)) {
		return new NNInfo (nearestNode);
	}

it work… but there is still a waring:
Canceled path because a new one was requested.
This happens when a new path is requested from the seeker when one was already being calculated.
For example if a unit got a new order, you might request a new path directly instead of waiting for the now invalid path to be calculated. Which is probably what you want.
If you are getting this a lot, you might want to consider how you are scheduling path requests.
UnityEngine.Debug:LogWarning(Object)

Hi

Here is an excerpt from a documentation page I am currently writing. Hopefully it will be helpful.

Couldn’t find a node close to the start point
When a path request is started it will query the pathfinding system for the closest node (a node is one tile in a grid graph, one triangle in a navmesh/recast graph and one point in a PointGraph) to the start point of the path.
This search has a limited range, though usually it is more than enough for all practical purposes.
So if you try to request a path starting from some point that is nowhere near any (walkable) nodes on any graph then this error will be logged.

Ways to resolve this error:

  • Make sure that the starting point of your path request is correct.
  • If you are using one of the included movement scripts, make sure that the AI starts somewhere reasonably close to the graph.
  • If you that your starting point is correct and you really do want to just extend the search, then increase the #AstarPath.maxNearestNodeDistance field.
    However know that having to search very far for the closest node may have an impact on performance.

Couldn’t find a node close to the end point
This is very similar to the error above. However when searching for the closest end node to the end point the system has an additional constraint in that the node
must not only be walkable, it must also be able to be reached from the starting node.
A common case when this error shows up is if the AI is say locked in a small room on one end of the map and gets an order to move to a point very far away.
When trying to find a node close to the end point it will have to search a very large distance since only the nodes inside that small room are reachable from the starting node.

Ways to resolve this error:

  • See previous error.

Canceled path because a new one was requested
The Seeker component only handles a single path request at a time. Since path requests are asynchronous it may happen
that a script tries to start to calculate a path before the previous path has been fully calculated.
There are several times when this is reasonable, for example the agent might have teleported to another part of the map, then any previous path calculations
would be pretty useless.
In any case, when this happens the Seeker will cancel the previous path request and set this error message as the reason for it failing.

If you are seeing this message even when you are just trying to calculate paths normally it may be because your script is not properly waiting for the previous path to be calculated before starting a new path calculation.
You can check if the Seeker is done calculating by calling the Seeker.IsDone method, or you could simply wait until the OnPathComplete callback is called.

hi,Sorry to late reply.
now I have a new problem:
ArgumentOutOfRangeException: Argument is out of range.
Parameter name: index
System.Collections.Generic.List`1[UnityEngine.Vector3].get_Item (Int32 index) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:54)
Pathfinding.Util.PathInterpolator.get_tangent () (at Assets/AstarPathfindingProject/Core/Misc/PathInterpolator.cs:25)
AILerp.ConfigureNewPath () (at Assets/AstarPathfindingProject/Core/AI/AILerp.cs:305)
AILerp.OnPathComplete (Pathfinding.Path _p) (at Assets/AstarPathfindingProject/Core/AI/AILerp.cs:281)
Seeker.OnPathComplete (Pathfinding.Path p, Boolean runModifiers, Boolean sendCallbacks) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:284)
Seeker.OnPathComplete (Pathfinding.Path p) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:252)
Pathfinding.Path.ReturnPath () (at Assets/AstarPathfindingProject/Core/Path.cs:692)
Pathfinding.Path.Pathfinding.IPathInternals.ReturnPath () (at Assets/AstarPathfindingProject/Core/Path.cs:746)
Pathfinding.PathReturnQueue.ReturnPaths (Boolean timeSlice) (at Assets/AstarPathfindingProject/Core/Misc/PathReturnQueue.cs:76)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:832)

how can solve this? thank you.

Hi

I have a vague recollection of fixing this bug in the 4.1 beta, though it might have been fixed earlier.
Which version are you using?

Sorry for late…
I am using beta version 4.1.7

I fixed it…
I add a function in PathInterpolator.cs. The function is:
public bool path0 {
get {
if (path != null) {
return path.Count > 0;
}

			return false;
		}
	}

and replace line 325 of AILerp.cs to var hadValidPath = interpolator.path0;

Is that right? thx!

I afraid there is memory leak or other runtime error be cause by my modify…