Hello,
I’m currently working on a project that involves a procedurally generated world so I can’t pre-scan the environment.
I’ve had a look at the Procedural example scene and it does help a little bit but the fundamental differences between the example scene and my scene are that…
My scene starts with literally one character object as opposed to the example scene which starts off with the “mine bot” and a ground plane which can be scanned at start and a path generated from that.
My character isn’t exactly controlled by the user input instead it is controlled by the changes the user makes to the environment. So this means, the graph has to be updated very frequently.
My target destination changes every frame.
I’ve tried manually rescanning the graph every second but it isn’t very performant and it’s recently been throwing errors when I try to manually rescan after adding the “Procedural Grid Mover” component.
I’ve read the documentation and it also seems daunting understanding everything at a go. Please, give me an idea of the route to take for me to achieve what I want.
IndexOutOfRangeException: Index was outside the bounds of the array.
Pathfinding.GridNode.GetConnections (System.Action`1[T] action) (at Assets/AstarPathfindingProject/Generators/NodeClasses/GridNode.cs:159)
Pathfinding.HierarchicalGraph.FindHierarchicalNodeChildren (System.Int32 hierarchicalNode, Pathfinding.GraphNode startNode) (at Assets/AstarPathfindingProject/Core/Misc/HierarchicalGraph.cs:304)
Pathfinding.HierarchicalGraph.RecalculateIfNecessary () (at Assets/AstarPathfindingProject/Core/Misc/HierarchicalGraph.cs:236)
Pathfinding.WorkItemProcessor.EnsureValidFloodFill () (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:231)
Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force) (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:324)
AstarPath.PerformBlockingActions (System.Boolean force) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:881)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:864)
Exception: Processing work items recursively. Please do not wait for other work items to be completed inside work items. If you think this is not caused by any of your scripts, this might be a bug.
Pathfinding.WorkItemProcessor.ProcessWorkItems (System.Boolean force) (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:265)
AstarPath.PerformBlockingActions (System.Boolean force) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:881)
AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:864)
There was an error generating the graphs:
System.NullReferenceException: Object reference not set to an instance of an object
at Pathfinding.HierarchicalGraph.AddDirtyNode (Pathfinding.GraphNode node) [0x00060] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Core\Misc\HierarchicalGraph.cs:160
at Pathfinding.HierarchicalGraph.OnCreatedNode (Pathfinding.GraphNode node) [0x0004c] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Core\Misc\HierarchicalGraph.cs:144
at Pathfinding.PathProcessor.InitializeNode (Pathfinding.GraphNode node) [0x00047] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Core\Misc\PathProcessor.cs:259
at AstarPath.InitializeNode (Pathfinding.GraphNode node) [0x00001] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Core\AstarPath.cs:1501
at Pathfinding.GraphNode..ctor (AstarPath astar) [0x0001d] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Core\Nodes\GraphNode.cs:98
at Pathfinding.GridNodeBase..ctor (AstarPath astar) [0x00000] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Generators\NodeClasses\GridNodeBase.cs:7
at Pathfinding.GridNode..ctor (AstarPath astar) [0x00000] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Generators\NodeClasses\GridNode.cs:8
at Pathfinding.GridGraph+<ScanInternal>d__85.MoveNext () [0x00168] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Generators\GridGenerator.cs:1082
at AstarPath+<ScanGraph>d__142.MoveNext () [0x00159] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Core\AstarPath.cs:1796
at AstarPath+<ScanAsync>d__141.MoveNext () [0x002f2] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Core\AstarPath.cs:1738
at Pathfinding.AstarPathEditor.MenuScan () [0x000e9] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Editor\AstarPathEditor.cs:1430
If you think this is a bug, please contact me on forum.arongranberg.com (post a new thread)
NullReferenceException: Object reference not set to an instance of an object
Pathfinding.AstarPathEditor.MenuScan () (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:1441)
Pathfinding.AstarPathEditor.DrawSceneGUISettings () (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:719)
Pathfinding.AstarPathEditor.OnSceneGUI () (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:668)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.SceneView.CallOnSceneGUI () (at <bf679006b1b84db2a5a44842ef13dc36>:0)
UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at <bf679006b1b84db2a5a44842ef13dc36>:0)
UnityEditor.SceneView.OnGUI () (at <bf679006b1b84db2a5a44842ef13dc36>:0)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <437ba245d8404784b9fbab9b439ac908>:0)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <bf679006b1b84db2a5a44842ef13dc36>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <bf679006b1b84db2a5a44842ef13dc36>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <bf679006b1b84db2a5a44842ef13dc36>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <bf679006b1b84db2a5a44842ef13dc36>:0)
UnityEditor.DockArea.OldOnGUI () (at <bf679006b1b84db2a5a44842ef13dc36>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.IMGUIContainer.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.UIElements.UIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <7be1a95b44f5474c9c1a5c5fd9c86b28>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <35bab3c7b0dc4999845bcfccc7758d96>:0)
There was an error generating the graphs:
System.NullReferenceException: Object reference not set to an instance of an object
at Pathfinding.GridGraph+<>c.<DestroyAllNodes>b__1_0 (Pathfinding.GraphNode node) [0x00001] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Generators\GridGenerator.cs:102
at Pathfinding.GridGraph.GetNodes (System.Action`1[T] action) [0x00014] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Generators\GridGenerator.cs:140
at Pathfinding.GridGraph.DestroyAllNodes () [0x00001] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Generators\GridGenerator.cs:97
at Pathfinding.NavGraph.Pathfinding.IGraphInternals.DestroyAllNodes () [0x00001] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Generators\Base.cs:379
at AstarPath+<ScanAsync>d__141.MoveNext () [0x00182] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Core\AstarPath.cs:1712
at Pathfinding.AstarPathEditor.MenuScan () [0x000e9] in C:\Users\User\Documents\Game Project\Infinity Maze\Infinity Maze Base\Assets\AstarPathfindingProject\Editor\AstarPathEditor.cs:1430
If you think this is a bug, please contact me on forum.arongranberg.com (post a new thread)
UnityEngine.Debug:LogError(Object)
Pathfinding.AstarPathEditor:MenuScan() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:1439)
Pathfinding.AstarPathEditor:DrawSceneGUISettings() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:719)
Pathfinding.AstarPathEditor:OnSceneGUI() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:668)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)