"This part should never be reached" has been reached in 5.4.6

I’m been getting errors in my grid graph since 5.4.6, it doesn’t happen every time I launch the game, but often. I have the ASTAR_GRID_NO_CUSTOM_CONNECTIONS compiler define.

AssertionException: Assertion failure. Value was Null
Expected: Value was not Null
UnityEngine.Assertions.Assert.Fail (System.String message, System.String userMessage) (at <ed2d546f2ee44b729486b69646ca06a6>:0)
UnityEngine.Assertions.Assert.IsNotNull[T] (T value, System.String message) (at <ed2d546f2ee44b729486b69646ca06a6>:0)
UnityEngine.Assertions.Assert.IsNotNull[T] (T value) (at <ed2d546f2ee44b729486b69646ca06a6>:0)
Pathfinding.ABPath.EndPointGridGraphSpecialCase (Pathfinding.Path+SearchContext& ctx, Pathfinding.NearestNodeConstraint nn, Pathfinding.NNInfo closestWalkableEndNode, UnityEngine.Vector3 originalEndPoint, System.Int32 targetIndex) (at ./Library/PackageCache/com.arongranberg.astar@85d89969624b/Pathfinders/ABPath.cs:274)
Pathfinding.ABPath.FindStartAndEndNodes (Pathfinding.Path+SearchContext& ctx, Pathfinding.NearestNodeConstraint& constraint) (at ./Library/PackageCache/com.arongranberg.astar@85d89969624b/Pathfinders/ABPath.cs:433)
Pathfinding.ABPath.Prepare (Pathfinding.Path+SearchContext& ctx) (at ./Library/PackageCache/com.arongranberg.astar@85d89969624b/Pathfinders/ABPath.cs:390)
Pathfinding.Path.Pathfinding.IPathInternals.Prepare (Pathfinding.Path+SearchContext& ctx) (at ./Library/PackageCache/com.arongranberg.astar@85d89969624b/Core/Pathfinding/Path.cs:1197)
Pathfinding.PathProcessor.CalculatePathsThreaded (Pathfinding.PathHandler pathHandler, Pathfinding.Sync.BlockableChannel`1+Receiver[T] receiver) (at ./Library/PackageCache/com.arongranberg.astar@85d89969624b/Core/Pathfinding/PathProcessor.cs:326)
UnityEngine.Debug:LogException(Exception)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler, Receiver) (at ./Library/PackageCache/com.arongranberg.astar@85d89969624b/Core/Pathfinding/PathProcessor.cs:395)
Pathfinding.<>c__DisplayClass27_0:<StartThreads>b__0() (at ./Library/PackageCache/com.arongranberg.astar@85d89969624b/Core/Pathfinding/PathProcessor.cs:122)
System.Threading.ThreadHelper:ThreadStart()

This happens after initially scanning the graph and using Seeker paths. Every agent in the game is stuck in-spot, but the grid graph is scanned. I also have a 2nd grid graph active at the same time (adding for completeness).

Thanks

Hi

Thank you for the bug report.

Can you post your graph settings and seeker settings?

Strange. It looks perfectly reasonable. Are you able to share a test project in which we can replicate the error?

Morning Aron,

I cannot replicate this in a sample project, apologies. The behaviour is likely being exposed by the more complex interactions of a real game. I am still presently stuck on 5.4.5. If there’s any specific infomation I can provide I’m happy to do so.

Thanks

@aron_granberg

Having looked into this a little it looks directly related to the changes you’ve made in GridGraph.cs

Ln 1506:

				return cost <= maxDistanceSqr ? new NNInfo(
					minNode,
					closest,
					cost
					) : NNInfo.Empty;

This will at some point evaluate false on a perfectly reasonable query and return NNInfo.Empty. This is likely due to the changes made in Ln 1381-1382 or Ln 1389-1407.

When this returns NNInfo.Empty the ABPath.cs:274 assert fails as this is null, when it should never be;

UnityEngine.Assertions.Assert.IsNotNull(gridNode2);

Could you please take it from here and see what’s gone on. There are some magic numbers and formula I can’t understand in GridGraph.cs’s changes.

Thank you

Was this solved?
I have a similar problem using a Grid Graph.
It looks like there is an error happening when I enter a region outside of the walkable nodes. In the image I have rendered the player as a thin blue capsule so you can see the position, and selected there is one of the enemies with the current setup. This error is also related with AIPath being disabled during the path calculation I think.

@aron_granberg I found the issue and it is related with a nn2.maxDistanceSqr being too small.
I did this to fix the issue.
Could you revise it and update the plugin with the fix in the next update?

var endNNInfo2 = gridGraph.GetNearest(originalEndPoint, ref nn2);
var gridNode2 = endNNInfo2.node as GridNode;
// Fix issue when nn2.maxDistanceSqr is too small
if (gridNode2 == null) {
	var minRadius = gridGraph.nodeSize * 1.5f;
	nn2.maxDistanceSqr = minRadius * minRadius;
	endNNInfo2 = gridGraph.GetNearest(originalEndPoint, ref nn2);
	gridNode2 = endNNInfo2.node as GridNode;
	if (gridNode2 == null)
		return false;
}
// We know we can find a node here, since closestWalkableEndNode.node exists
UnityEngine.Assertions.Assert.IsNotNull(gridNode2);
1 Like

Great find, I let Aron know about it :+1:

1 Like