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).
UPDATE:
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;
SetPath(p);
}
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)
UnityEngine.Debug:LogException(Exception)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:407)
And
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 ()
And
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 ()