Support Forum

Closest Point Ignored when Nodelink2 tag is not traversable

I have extended the Nodelink2 class so that I can assign a Tag to the startNode and endNode.

I can then set a Seeker to not traverse that link by turning off the Tag in the seeker parameters. So far so good.

The problem is that when a seeker is unable to reach the destination, due to being disallowed from traversing the NodeLink, the seekers gets no path at all.

The normal/expected behaviour is that the seeker should find a path as close to the destination as possible. If I were to completely disable the Nodelink so that there is no link at all then the seeker reverts back to normal behaviour and goes as far as it can towards the destination.

So how I can disable seeker access to a tagged Nodelink, while still maintaining the “Find Closest Point” behaviour?

It’s giving this error in debug console:

Path Failed : Computation Time 0.00 ms Searched Nodes 597
Error: Searched all reachable nodes, but could not find target. This can happen if you have nodes with a different tag blocking the way to the goal. You can enable path.calculatePartial to handle that case workaround (though this comes with a performance cost).


So I can kind of get it working by adding p.calculatePartial = true; to the AIBase like this:

public virtual void SearchPath () {
			if (float.IsPositiveInfinity(destination.x)) return;
			if (onSearchPath != null) onSearchPath();

			Vector3 start, end;
			CalculatePathRequestEndpoints(out start, out end);

			// Request a path to be calculated from our current position to the destination
			ABPath p = ABPath.Construct(start, end, null);
			p.calculatePartial = true;

Which does work, but I change the seeker traversable tag on/off at Runtime then I get an error like this:

Exception: Some path is not cleaning up the flag1 field. This is a bug.
Pathfinding.ABPath.CompleteWith (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Pathfinders/ABPath.cs:589)
Pathfinding.ABPath.CalculateStep (System.Int64 targetTick) (at Assets/AstarPathfindingProject/Pathfinders/ABPath.cs:624)
Pathfinding.Path.Pathfinding.IPathInternals.CalculateStep (System.Int64 targetTick) (at Assets/AstarPathfindingProject/Core/Path.cs:838)
Pathfinding.PathProcessor.CalculatePathsThreaded (Pathfinding.PathHandler pathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:350)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:407)


Unhandled exception during pathfinding. Terminating.
UnityEngine.Debug:LogError (object)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:408)
Pathfinding.PathProcessor/<>c__DisplayClass24_0:<.ctor>b__0 () (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:110)
System.Threading.ThreadHelper:ThreadStart ()


Error : This part should never be reached.
UnityEngine.Debug:LogError (object)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:418)
Pathfinding.PathProcessor/<>c__DisplayClass24_0:<.ctor>b__0 () (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:110)
System.Threading.ThreadHelper:ThreadStart ()


This sure looks like a bug, but I have not been able to replicate it, even after trying for a long time.
Would you mind posting all the code and specifics of what you are doing?

In particular, it would be interesting to see how you configured the node links, and how they are placed in the world.
Also, which version of the package are you using?

I have made a new very simple project to show the error. It seems to happen randomly after a moved around for awhile. Please see video here:

It takes about 1 minute then error appears and pathfinding breaks, but sometimes the error comes much quicker.

In my sample scene there are 2 characters, one that can climb up the link and one that cannot.

I’ve put my scene files here:

If you just make a new project with these files it should work (you must install the A* Pathfinding and Input Manager packages).

It tried to keep it as simple as possible to see the error.

Note that this was created with Unity 2021.3.11f and latest Pathfinding (4.2.18). But my real project is using latest Beta Unity version, but same error, so i think it’s not a version issue.

Thanks! I managed to replicate it!
It was indeed a sneaky bug.

I’ll add a fix for this to the next beta version (and I’ll backport it to the non-beta).

To the beta, I’ll also add a field to the NodeLink2 script for setting a tag.

Thanks, if the fix is relatively simple can you please just post the code lines that were at issue so that i don’t need to wait for the next version release? This bug is really hampering me as I need to restrict certain characters ability to use certain node links.

Here’s the diff:

commit 39b1412e51714a03c01195532aff72af5d65f388
Author: Aron Granberg <>
Date:   Fri Nov 11 11:02:36 2022 +0100

    Fixed an exception could in rare circumstances be thrown when using ABPath.calculatePartial.

diff --git a/Assets/AstarPathfindingProject/Pathfinders/ABPath.cs b/Assets/AstarPathfindingProject/Pathfinders/ABPath.cs
index e8ffa4a6..8ab0e50d 100644
--- a/Assets/AstarPathfindingProject/Pathfinders/ABPath.cs
+++ b/Assets/AstarPathfindingProject/Pathfinders/ABPath.cs
@@ -514,6 +514,12 @@ namespace Pathfinding {
 		void CompletePartial (PathNode node) {
+			// We will change the end node, so we have to clean up the previous end node to not
+			// leave it with stale data.
+			var pathEndNode = pathHandler.GetPathNode(endNode);
+			pathEndNode.flag1 = false;
+			pathEndNode.flag2 = false;
 			CompleteState = PathCompleteState.Partial;
 			endNode = node.node;
 			endPoint = endNode.ClosestPointOnNode(originalEndPoint);
diff --git a/Assets/AstarPathfindingProject/changelog.cs b/Assets/AstarPathfindingProject/changelog.cs
index baa8b523..a0af8dc5 100644
--- a/Assets/AstarPathfindingProject/changelog.cs
+++ b/Assets/AstarPathfindingProject/changelog.cs
@@ -1,6 +1,9 @@
 /** \page changelog Changelog
+- 4.3.62
+	- Fixed an exception could in rare circumstances be thrown when using \reflink{ABPath.calculatePartial}.
 - 4.3.61 (2022-11-09)
 	- Added a documentation page on the architecture of the package: \ref architecture.
 	- Added a tutorial on migrating from Unity's pathfinding to this package: \ref migrating-from-unity.
1 Like

I’m having trouble with this still.

When I go into “Packages” directory and try to edit the ABPath.cs to apply this fix; every time it compiles the changes just get reset to the original file.

How can I add these lines? Note that I’m using the version bought through the unity asset store. I tried to use the beta version but it create a ton of errors in my game. I just want to be able to add this one fix above.