Support Forum

Unhandled exception during pathfinding. Terminating. Error : This part should never be reached

Hello,
I’m having a big problem since my game is now Live and people are experiencing this.
This happens only in RELEASE build and not in editor or Development Build

IndexOutOfRangeException: Index was outside the bounds of the array.
  at Pathfinding.EuclideanEmbedding.GetHeuristic (System.Int32 nodeIndex1, System.Int32 nodeIndex2) [0x0003e] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.Path.CalculateHScore (Pathfinding.GraphNode node) [0x00068] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.TriangleMeshNode.Open (Pathfinding.Path path, Pathfinding.PathNode pathNode, Pathfinding.PathHandler handler) [0x000bf] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.ABPath.CalculateStep (System.Int64 targetTick) [0x0005e] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.Path.Pathfinding.IPathInternals.CalculateStep (System.Int64 targetTick) [0x00000] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.PathProcessor.CalculatePathsThreaded (Pathfinding.PathHandler pathHandler) [0x00097] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler)
Pathfinding.<>c__DisplayClass24_0:<.ctor>b__0()
System.Threading.ThreadHelper:ThreadStart_Context(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
System.Threading.ThreadHelper:ThreadStart()

IndexOutOfRangeException: Index was outside the bounds of the array.
  at Pathfinding.EuclideanEmbedding.GetHeuristic (System.Int32 nodeIndex1, System.Int32 nodeIndex2) [0x0003e] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.Path.CalculateHScore (Pathfinding.GraphNode node) [0x00068] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.TriangleMeshNode.Open (Pathfinding.Path path, Pathfinding.PathNode pathNode, Pathfinding.PathHandler handler) [0x000bf] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.ABPath.CalculateStep (System.Int64 targetTick) [0x0005e] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.Path.Pathfinding.IPathInternals.CalculateStep (System.Int64 targetTick) [0x00000] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
  at Pathfinding.PathProcessor.CalculatePathsThreaded (Pathfinding.PathHandler pathHandler) [0x00097] in <95793f5e4bc24ea6b4a84f989700de0f>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler)
Pathfinding.<>c__DisplayClass24_0:<.ctor>b__0()
System.Threading.ThreadHelper:ThreadStart_Context(Object)
System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object)
System.Threading.ThreadHelper:ThreadStart()

Unhandled exception during pathfinding. Terminating.
Unhandled exception during pathfinding. Terminating.
Error : This part should never be reached.
Error : This part should never be reached.

I’m reproducing this when the target (which enemies will find and walk to) is not on the ground graph. Imagine that the Player is the target and when enemies are instantiating (with their pathfinding script attached) and if the player is not on the ‘ground’ at that moment the exception happens. Then everything doesn’t work since “Unhandled exception during pathfinding. Terminating.
Error : This part should never be reached.”

Release build only!

Is this a “heuristic mode” problem? Should I disable it or increase heuristicScale from 1 to 2 for example?

Hi

Thank you for reporting this bug.
Do you change any settings for the heuristic optimization during runtime?

In the meantime, you can work around this problem by disabling heuristic optimization in A* Inspector → Settings.

Hi, no I do not change any settings during runtime. I’m using it pretty straight forward.
I’ve increased the heuristicScale from 1 to 2 and it seems the problem disappeared does that makes sense or should I remove it to be sure?