I am creating an elevator and therefore I am using a moving platform. After the platform stops moving I am updating the layered grid graph using specified bounds. This works fine until I move the platform down - during the graph update the nodes that were created at top position are now destroyed and I am getting the exceptions
InvalidOperationException: A node in a ShadowGridGraph contained a connection to a destroyed ShadowNode.
Pathfinding.HierarchicalGraph+JobRecalculateComponents+<>c.<FindHierarchicalNodeChildren>b__12_0 (Pathfinding.GraphNode neighbour, Pathfinding.HierarchicalGraph+JobRecalculateComponents+Context& context) (at ./Library/PackageCache/com.arongranberg.astar@4.3.88/Core/Pathfinding/HierarchicalGraph.cs:442)
Pathfinding.LevelGridNode.GetConnections[T] (Pathfinding.GraphNode+GetConnectionsWithData`1[T] action, T& data, System.Int32 connectionFilter) (at ./Library/PackageCache/com.arongranberg.astar@4.3.88/Graphs/Nodes/LevelGridNode.cs:175)
Pathfinding.HierarchicalGraph+JobRecalculateComponents.FindHierarchicalNodeChildren (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, Pathfinding.GraphNode startNode) (at ./Library/PackageCache/com.arongranberg.astar@4.3.88/Core/Pathfinding/HierarchicalGraph.cs:444)
Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Library/PackageCache/com.arongranberg.astar@4.3.88/Core/Pathfinding/HierarchicalGraph.cs:537)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <e97d84204f8d4aef92b538c5bab948f1>:0)
NullReferenceException: Object reference not set to an instance of an object
Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Library/PackageCache/com.arongranberg.astar@4.3.88/Core/Pathfinding/HierarchicalGraph.cs:503)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <e97d84204f8d4aef92b538c5bab948f1>:0)
I think that it might be caused by a subsequent graph update that effectively destroys some nodes. My use case is like this:
- the lift is starting at the bottom position. the platform is set to be walkable and the graph is scanned. Everything is ok.
- now the lift goes up, and at the top position, the graph is scanned once again. Now the nodes (probably in the higher layer) are created and set up. Everything is ok.
- now the lift goes down. At the bottom position, the graph is scanned. Now the nodes created in previous step aren’t valid so they got removed and the exception is being thrown for whatever reason.