Error : This part should never be reached

Hi,

I am working on a Tactical turn by turn game and i have one node on my GridGraph that make the PathProcessor crash. All the other node can be reach without problems.

The exceptions i receive (when using AstarPath.StartPath(path), and when the path contain this node) are :

IndexOutOfRangeException: Index was outside the bounds of the array.
Pathfinding.PathHandler.GetPathNode (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Core/PathHandler.cs:196)
Pathfinding.ABPath.Prepare () (at Assets/AstarPathfindingProject/Pathfinders/ABPath.cs:454)
Pathfinding.Path.Pathfinding.IPathInternals.Prepare () (at Assets/AstarPathfindingProject/Core/Path.cs:832)
Pathfinding.PathProcessor.CalculatePathsThreaded (Pathfinding.PathHandler pathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:328)
UnityEngine.Debug:LogException(Exception)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:407)
Pathfinding.<>c__DisplayClass24_0:<.ctor>b__0() (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:110)
System.Threading.ThreadHelper:ThreadStart()

Unhandled exception during pathfinding. Terminating.
UnityEngine.Debug:LogError(Object)
Pathfinding.PathProcessor:CalculatePathsThreaded(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:408)
Pathfinding.<>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(PathHandler) (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:418)
Pathfinding.<>c__DisplayClass24_0:<.ctor>b__0() (at Assets/AstarPathfindingProject/Core/Misc/PathProcessor.cs:110)
System.Threading.ThreadHelper:ThreadStart()

I generate the GridGraph by script (on editor mode, not in runtime) as follow :

private void CreateAStarGrid()
    {
        AstarPath.FindAstarPath();
        AstarData data = AstarPath.active.data;
        string graphName = "GridGraph_" + gameObject.scene.name;
        if (data != null && data.graphs != null && data.graphs.Length > 0 && data.graphs[0].name == graphName)
        {
            data.RemoveGraph(data.graphs[0]);
        }

        GridGraph gg = data.AddGraph(typeof(GridGraph)) as GridGraph;
        gg.name = graphName;
        gg.center = gameObject.transform.position;
        gg.SetDimensions(width, height, nodeSize);
        gg.neighbours = NumNeighbours.Four;
        GraphCollision c = new GraphCollision
        {
            collisionCheck = false,
            heightCheck = false
        };
        gg.collision = c;
        gg.showMeshOutline = false;
        gg.showMeshSurface = false;
        gg.showNodeConnections = false;

        AstarPath.active.Scan(gg);
    }

I have try to regenerate different Graph with different sizes, changed the coordinate for the grid but it is the same, i have one node that make the path finder crash.

The exception seems to originate from the PathHandler method :

public PathNode GetPathNode (GraphNode node) {
			return nodes[node.NodeIndex];
		}

And the node index is : 268435454.

I am using Unity 2019.3.0f3 on Window 10.

Any ideas what i do wrong ?

Hi

That is really strange. The node index shouldn’t be able to be that large. Are you modifying the nodes in any way after the graph has been scanned?

Hi,

Nop. I read and reference node on lists, but i don’t set node value.
I use the FakePath function one time but i give it the node list and a vector list.

ABPath fakePath = ABPath.FakePath(GetNodePositions(currentPath), currentPath);

…

private List<Vector3> GetNodePositions(List<GraphNode> nodes)
    {
        List<Vector3> positions = new List<Vector3>();
        foreach(GraphNode g in nodes)
        {
            positions.Add((Vector3)g.position);
        }
        return positions;
    }

But if work fine, except when i go on the “faulty” node ^^’

Which version of the package are you using?
Is the faulty node always in the same position, and is that position special in some way?

I use the version 4.3.10

The node seems to always have roughly the same coordinate (-3.5,0.0,-1.5) ± 0.2.
But i do not see anything special with this coordinates.

I have put a “very” minimal scene in place and the problem seems to be resolved.
By process of elimination i should be able to find what was the cause of the interference.

If i find it, i will post it here.

Thanks for the time :slight_smile:

1 Like