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 ?