I’ve started getting stack overflow errors with A* Pathfinding 3.1.4. I recently upgraded from 3.0.9 and I wasn’t getting the error in that version, and the problem seems to be happening in code that I haven’t changed since the upgrade. I’m using Unity 4.
Here’s the error message, it recurses in this function about 1000 times:
StackOverflowException: The requested operation caused a stack overflow.
at Pathfinding.Nodes.GridNode.UpdateAllG (Pathfinding.NodeRun nodeR, Pathfinding.NodeRunData nodeRunData) [0x0007e] in C:\Projects\TowerDefense\Assets\AstarPathfindingProject\Generators\odeClasses\GridNode.cs:205
(Filename: Assets/AstarPathfindingProject/Generators/NodeClasses/GridNode.cs Line: 205)
I’ve got one grid graph with 2542 nodes, and I’m getting this when I UpdateGraphs with a GraphUpdateObject. Here’s my code.
void SetPathfindingWalkable(bool walkable)
{
GraphUpdateObject guo = new GraphUpdateObject (pathfindingCollider.bounds);
if(walkable)
guo.addPenalty = -PathfindingPenalty;
else
guo.addPenalty = PathfindingPenalty;
guo.updatePhysics = false;
if(AstarPath.active)
AstarPath.active.UpdateGraphs (guo);
}
I’m making a tower defense game where I’m constantly adding and removing towers, and this function is called every time a building is added or removed. I get the error after a random number of updates. I’ve tried with automatic multithreading, one, two, and none, and I still get the error. Any idea of how this could be fixed?