Getting Exception while updating graphs:

Hi,

I have version 3.8.6 pro latest on store and use Automatic High Load

I get this error:

Exception while updating graphs:
System.NullReferenceException: Object reference not set to an instance of an object
at AstarPath+c__AnonStorey3.<>m__0 (Pathfinding.GraphNode node) [0x00002] in \Assets\AstarPathfindingProject\Core\AstarPath.cs:1862
at Pathfinding.GridGraph.GetNodes (Pathfinding.GraphNodeDelegateCancelable del) [0x00035] in \Badiya\Assets\AstarPathfindingProject\Generators\GridGenerator.cs:106
at AstarPath.FloodFill () [0x000fa] in \Badiya\Assets\AstarPathfindingProject\Core\AstarPath.cs:1912
at AstarPath.ProcessGraphUpdatesAsync (System.Object _astar) [0x000ab] in \Assets\AstarPathfindingProject\Core\AstarPath.cs:1393
UnityEngine.Debug:LogError(Object)
AstarPath:ProcessGraphUpdatesAsync(Object) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1398)

so the steps are:
1- I start the game with no grids at all.
2- I add a grid for the player to move with him after the game loads not instantly at awake or start
var graph = AstarPath.active.astarData.AddGraph(typeof(GridGraph)) as GridGraph;

then scan it:

AstarPath.RegisterSafeUpdate
            (
                delegate ()
                {
                    playerGraph.ScanInternal();

                    //Make sure the above graph update is done now
                    AstarPath.active.FlushGraphUpdates();
                }
            );

            //If you want to make sure the update is called directly instead of
            //at the end of this frame or after a few frames.
            AstarPath.active.FlushThreadSafeCallbacks();

3- then other graphs are added also by the method above.

4- the player graph moves with him using your grid mover script

5- the other graphs are moved by changing the center of the graph then call the same above scan

 AstarPath.RegisterSafeUpdate
                (
                    delegate ()
                    {
                    AstarPath.active.Scan();

                        //Make sure the above graph update is done now
                        AstarPath.active.FlushGraphUpdates();
                    }
                );

                //If you want to make sure the update is called directly instead of
                //at the end of this frame or after a few frames.
                AstarPath.active.FlushThreadSafeCallbacks();

Note:
I do not get any errors or any thing wrong except the error above but then everything is normal

So is there anything wrong am I doing?

Hi

I am not sure why you are getting that error, but I think that might be something I have fixed in the beta version. You can try downloading that (the beta version 3.8.5 actually has a few features that haven’t made it into the main branch yet, I know the version numbers are a bit messed up at the moment, sorry about that).

A few other notes though.
ScanInternal is an internal method you can call it, but if you want to scan all graphs you really should use AstarPath.active.Scan instead as that takes care of many other things as well. The Scan methods are also synchronous, calling AstarPath.active.FlushGraphUpdates() after does not impact the scanning since it has already completed. If you want to scan a single graph you might be better off using a GraphUpdateObject with a very large bounds and the nnConstraint.graphMask field set to only affect a single graph (or all graphs except the player graph if that is what you want to accomplish) as there is currently no API call that you can use (except the internal method ScanInternal to scan a single graph).