Support Forum

ProceduralGridMover bug

I have an AIPath, a GridGraph and a ProceduralGridMover.
I make the AIPath follow my character, and the ProceduralGridMover moves the GridGraph to follow my character.

However, when the GridGraph moves, the AIPath suddenly stops moving and I get a lot of errors starting with ProceduralGridMover.

IndexOutOfRangeException: Index was outside the bounds of the array.
Pathfinding.ProceduralGridMover+<UpdateGraphCoroutine>d__13.MoveNext () (at Assets/AstarPathfindingProject/Utilities/ProceduralGridMover.cs:271)
Pathfinding.ProceduralGridMover+<>c__DisplayClass12_0.<UpdateGraph>b__0 (Pathfinding.IWorkItemContext context, System.Boolean force) (at Assets/AstarPathfindingProject/Utilities/ProceduralGridMover.cs:153)
UnityEngine.Debug:LogException(Exception, Object)
Pathfinding.<>c__DisplayClass12_0:<UpdateGraph>b__0(IWorkItemContext, Boolean) (at Assets/AstarPathfindingProject/Utilities/ProceduralGridMover.cs:158)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean) (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:300)
AstarPath:PerformBlockingActions(Boolean) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:881)
AstarPath:Update() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:864)

Then, GridNode,

IndexOutOfRangeException: Index was outside the bounds of the array.
Pathfinding.GridNode.GetConnections (System.Action`1[T] action) (at Assets/AstarPathfindingProject/Generators/NodeClasses/GridNode.cs:165)
Pathfinding.HierarchicalGraph.FindHierarchicalNodeChildren (System.Int32 hierarchicalNode, Pathfinding.GraphNode startNode) (at Assets/AstarPathfindingProject/Core/Misc/HierarchicalGraph.cs:304)
Pathfinding.HierarchicalGraph.RecalculateIfNecessary () (at Assets/AstarPathfindingProject/Core/Misc/HierarchicalGraph.cs:236)
Pathfinding.WorkItemProcessor.EnsureValidFloodFill () (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:231)
Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force) (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:325)
AstarPath.PerformBlockingActions (System.Boolean force) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:881)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:864)

Then every frame, I get this error,

Exception: Processing work items recursively. Please do not wait for other work items to be completed inside work items. If you think this is not caused by any of your scripts, this might be a bug.
Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force) (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:335)
AstarPath.PerformBlockingActions (System.Boolean force) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:881)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:864)

So, 900 frames = 900 errors.


The initial error comes from,

var node = buffer[pz + x]; //IndexOutOfRangeException

I tried,

Debug.LogError($"{buffer.Length}, {x}, {pz}");
//Output: 22750, 130, 22620

My graph is 130*175 = 22750, which makes sense for buffer.Length.

22620+130 = 22750, which means it is indeed trying to access an index that does not exist.


Checked,

Debug.LogError($"{buffer.Length}, {x}, {pz}, {xmin}, {xmax}, {z >= recalculateRect.ymin && z < recalculateRect.ymax}");
//Output: 22750, 130, 22620, 0, 175, True

I’m not sure but this piece of code looks suspicious,


						if (z >= recalculateRect.ymin && z < recalculateRect.ymax) {
							xmin = 0;
							xmax = depth;
						} else {
							xmin = recalculateRect.xmin;
							xmax = recalculateRect.xmax;
						}

I feel like it should say, xmax = width;

Hi

Sorry for the late reply.
You might be able to try the beta version. I have rewritten a large chunk of the ProceduralGridMover there. It’s possible that this was a bug that was fixed in that rewrite.

See A* Pathfinding Project