GraphUpdateObject and recast

I am trying to update a recast graph with GraphUpdateObject. Unfortunately it keeps throwing erros no matter what I do. I already added GraphUpdateThreading.UnityThread in CanUpdateAsync to fix the threading related error and change the thread count to none or any number without any progress.

This is the error I get:
Error while updating graphs
System.InvalidOperationException: No Voxelizer object. UpdateAreaInit should have been called before this function.
at Pathfinding.RecastGraph.UpdateArea (Pathfinding.GraphUpdateObject guo) [0x001da] in \Assets\AstarPathfindingProject\Generators\RecastGenerator.cs:871
at AstarPath.ProcessGraphUpdates (Boolean force) [0x001b9] in \Assets\AstarPathfindingProject\Core\AstarPath.cs:1081
UnityEngine.Debug:LogError(Object)
AstarPath:ProcessGraphUpdates(Boolean) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1083)
AstarPath:ProcessWorkItems(Boolean) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:816)
AstarPath:PerformBlockingActions(Boolean, Boolean) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:722)
AstarPath:Update() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:679)

Hi

Try the latest beta that was just released: arongranberg.com/astar/download
I think it fixes that issue.

No, it doesn’t. I get the “CompareBaseObjectsInternal can only be called from the main thread.” error and this one:

Exception while updating graphs:
System.ArgumentException: CompareBaseObjectsInternal can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
at (wrapper managed-to-native) UnityEngine.Object:CompareBaseObjectsInternal (UnityEngine.Object,UnityEngine.Object)
at UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) [0x00000] in C:\BuildAgent\work\d63dfc6385190b60\artifacts\EditorGenerated\UnityEngineObject.cs:49
at UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) [0x00000] in C:\BuildAgent\work\d63dfc6385190b60\artifacts\EditorGenerated\UnityEngineObject.cs:162
at Pathfinding.GraphNode…ctor (.AstarPath astar) [0x00006] in \Assets\AstarPathfindingProject\Core\odes\GraphNode.cs:52
at Pathfinding.MeshNode…ctor (.AstarPath astar) [0x00000] in :0
at Pathfinding.TriangleMeshNode…ctor (.AstarPath astar) [0x00000] in :0
at Pathfinding.RecastGraph.CreateTile (Pathfinding.Voxels.Voxelize vox, VoxelMesh mesh, Int32 x, Int32 z) [0x0022f] in \Assets\AstarPathfindingProject\Generators\RecastGenerator.cs:1560
at Pathfinding.RecastGraph.BuildTileMesh (Pathfinding.Voxels.Voxelize vox, Int32 x, Int32 z) [0x00266] in \Assets\AstarPathfindingProject\Generators\RecastGenerator.cs:1476
at Pathfinding.RecastGraph.UpdateArea (Pathfinding.GraphUpdateObject guo) [0x0025e] in \Assets\AstarPathfindingProject\Generators\RecastGenerator.cs:900
at AstarPath.ProcessGraphUpdatesAsync (System.Object _astar) [0x00074] in \Assets\AstarPathfindingProject\Core\AstarPath.cs:1187

I haven’t changed the source files, tho.

I’m also having this exact problem and even on the latest pro beta. Any idea when this will be addressed?

Hi

Thanks for the stacktrace.
I hadn’t thought of that edge case.
To solve it (hopefully). Open up the GraphNode.cs script and find the GraphNode constructor. Change the “astar != null” to !System.Object.ReferenceEquals (astar, null)
like
/** Constructor for a graph node. */ public GraphNode (AstarPath astar) { if (!System.Object.ReferenceEquals (astar, null)) { this.nodeIndex = astar.GetNewNodeIndex(); astar.InitializeNode (this); } else { throw new System.Exception ("No active AstarPath object to bind to"); } }
I really wonder why I never got that exception during my testing as it seems like I really should have…

Well, it doesn’t throw any errors anymore, but it also doesn’t look like the graph is being updated correctly. I tried both GraphUpdateScene and GraphUpdateObject, with and without physics, without any success. In fact, I can see the graph is refreshed, but no changes are being made.

Hi

Could you show me some screenshots of your settings?
Are the included example scenes working? (e.g the Terrain scene or most other scenes which place an obstacle if you press the P key).