Ok now i’m having a completely different issue. Tried baking my graphs by exporting like I always do.
So I used this:
foreach (var graph in AstarPath.active.astarData.graphs)
{
if (graph != null)
{
AstarPath.active.astarData.RemoveGraph(graph);
}
}
to remove the graphs after I baked the first batch but then when I create a graph it throws this error:
NullReferenceException: Object reference not set to an instance of an object
Pathfinding.GridNode.FloodFill (System.Collections.Generic.Stack`1 stack, UInt32 region) (at Assets/AstarPathfindingProject/Generators/NodeClasses/GridNode.cs:235)
AstarPath+c__AnonStorey3.<>m__0 (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1902)
Pathfinding.GridGraph.GetNodes (Pathfinding.GraphNodeDelegateCancelable del) (at Assets/AstarPathfindingProject/Generators/GridGenerator.cs:106)
AstarPath.FloodFill () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1912)
AstarPath.ScanLoop (Pathfinding.OnScanStatus statusCallback) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:2134)
AstarPath.Scan () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:2017)
Edit: I found you little bug and fixed it. As you can see in AstarData.cs:500 -
bool foundEmpty = false;
for (int i = 0; i < graphs.Length; i++) {
if (graphs[i] == null) {
graphs[i] = graph;
graph.graphIndex = (uint)i;
foundEmpty = true;
break; // This break is missing in the original code. I added it
}
}
Without the added break, it will just replace all nulls (as many as the number of graphs removed beforehand) with the current one. Please fix it
Also, it seems like the threading bug still happens:
IndexOutOfRangeException: Array index is out of range.
at Pathfinding.GridGraph.GetNearestForce (Vector3 position, Pathfinding.NNConstraint constraint) [0x00614] in Assets\AstarPathfindingProject\Generators\GridGenerator.cs:778
at AstarPath.GetNearest (Vector3 position, Pathfinding.NNConstraint constraint, Pathfinding.GraphNode hint) [0x0017d] in Assets\AstarPathfindingProject\Core\AstarPath.cs:2893
at Pathfinding.ABPath.Prepare () [0x0009e] in Assets\AstarPathfindingProject\Pathfinders\ABPath.cs:195
at AstarPath.CalculatePathsThreaded (System.Object _threadInfo) [0x000d2] in Assets\AstarPathfindingProject\Core\AstarPath.cs:2501
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
AstarPath:CalculatePathsThreaded(Object) (at Assets\AstarPathfindingProject\Core\AstarPath.cs:2597)
(Filename: Assets/AstarPathfindingProject/Generators/GridGenerator.cs Line: 778)
Then
Unhandled exception during pathfinding. Terminating.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object)
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
AstarPath:CalculatePathsThreaded(Object) (at \Assets\AstarPathfindingProject\Core\AstarPath.cs:2598)
And then
Error : This part should never be reached.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object)
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
AstarPath:CalculatePathsThreaded(Object) (at \Assets\AstarPathfindingProject\Core\AstarPath.cs:2604)
Also, after upgrading i’m starting to get lots of these:
Guid Conflict when importing graphs additively. Imported graph will get a new Guid.
This message is (relatively) harmless.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object)
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogWarning(Object)
Pathfinding.AstarData:DeserializeGraphsPartAdditive(AstarSerializer) (at Assets\AstarPathfindingProject\Core\AstarData.cs:352)
Pathfinding.AstarData:DeserializeGraphsAdditive(Byte) (at Assets\AstarPathfindingProject\Core\AstarData.cs:292)
Pathfinding.AstarData:DeserializeGraphs(Byte) (at Assets\AstarPathfindingProject\Core\AstarData.cs:277)
GraphBake:ImportGraphs(String) (at Assets\Scripts\AI\Baking\GraphBake.cs:372)
InfluenceMapManager:LoadBakedGraphs(String, Single, String) (at Assets\Scripts\AI\Influence Maps\InfluenceMapManager.cs:152)
InfluenceMapManager:OnPostSegmentSpawnServer() (at Assets\Scripts\AI\Influence Maps\InfluenceMapManager.cs:129)
ActionExtensions:SafeInvoke(Action) (at Assets\Scripts\Utils\ActionExtensions.cs:11)
Assets.Scripts.Managers.GameFlowManager:OnCompletedLoadingSegmentServer() (at Assets\Scripts\Managers\GameFlowManager.cs:655)
ActionExtensions:SafeInvoke(Action) (at Assets\Scripts\Utils\ActionExtensions.cs:11)
Assets.Scripts.Managers.c__Iterator2:MoveNext() (at Assets\Scripts\Managers\SegmentManager.cs:369)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
(Filename: Assets/AstarPathfindingProject/Core/AstarData.cs Line: 352)