NullReferenceException on start - version 4.1.11


I have been using A* for a few months without getting any errors, but today I started the scene and got this

This is the full message:

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.RecastGraph.BuildTileMesh (Pathfinding.Voxels.Voxelize vox, Int32 x, Int32 z, Int32 threadIndex) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:853)
Pathfinding.RecastGraph+c__Iterator1+c__AnonStorey2.<>m__0 (Int2 tile, Int32 threadIndex) (at Assets/AstarPathfindingProject/Generators/RecastGenerator.cs:654)
Pathfinding.Util.ParallelWorkQueue`1[Pathfinding.Int2].RunTask (Int32 threadIndex) (at Assets/AstarPathfindingProject/Utilities/AstarParallel.cs:91)

The error points to my NPC using A and the last message points to the A object itself**

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.Util.ObjectPool`1[Pathfinding.BBTree].Release (Pathfinding.BBTree& obj) (at Assets/AstarPathfindingProject/Core/Misc/ObjectPool.cs:39)
Pathfinding.NavmeshBase.OnDestroy () (at Assets/AstarPathfindingProject/Generators/NavmeshBase.cs:214)
Pathfinding.NavGraph.Pathfinding.IGraphInternals.OnDestroy () (at Assets/AstarPathfindingProject/Generators/Base.cs:344)
Pathfinding.AstarData.ClearGraphs () (at Assets/AstarPathfindingProject/Core/AstarData.cs:293)
Pathfinding.AstarData.OnDestroy () (at Assets/AstarPathfindingProject/Core/AstarData.cs:302)
AstarPath.OnDestroy () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1300)

If I start the game again, I cannot replicate it, it just happened once, but may ruin the experience for the player.


Do you think you could post the exact line which throws this exception? (line numbers change all the time and it’s tricky for me to look them up).

The first error is the cause of all the other ones though, so you don’t need to worry about the rest.

The rest of the errors are on the other NPCs using A*, except the last error which points to the A* game object.

This is the line of code for that error RecastGenerator.cs 853


RecastGenerator.cs 654

			tiles[tile.x + tile.y*tileXCount] = BuildTileMesh(voxelizers[threadIndex], tile.x, tile.y,     threadIndex);

AstarParallel.cs 91

action(tile, threadIndex);

That is really strange… I see no way for any of those variables to be null, even if it would have been caused by a multithreading race condition…