Graph generation for a large predefined world

  • A* Pro version: 5.3.6
  • Unity version: 6000.0.47f1

Hello.

I’ve started to use this package recently, but cannot get it to work in a way that seems ideal to me (however, maybe I’m wrong here, as I’m new to it).

I have a large predefined world (32 768 x 32 768) with multiplayer, where chunks are loaded as additive scenes. So far, I have tried the following approaches:

  1. One large recast graph, I’ve set ASTAR_RECAST_LARGER_TILES and made tiles big in size (4096) to fit the tile limit, opened all scenes, snapped bounds to scene, ran scan, but Unity crashed after ten minutes.

  2. Bake recast graphs for all scenes separately and serialize them. At runtime, I load them and they work fine, but only within their own boundaries. No connections exist between graphs (even if they’re overlapping), and as I saw from answers in other topics, stitching graphs is not recommended.

I’m aware that I have the option to use the one graph and ProceduralGraphMover as in the examples, but as the world is predefined, I hoped to avoid rebuilding a graph at runtime if other options are possible.

So, my question is, what is the best approach here? Could be multiple graphs connected, or maybe loaded into a single graph? Or is ProceduralGraphMover the only reasonable solution for now?

Apologies if it was already answered, I’ve checked the forum, and saw similar topics, but the solutions in them don’t work yet for my case.

Thanks.

Hi

Did you happen to get any stack traces?

I would recommend checking out the NavmeshPrefab component

You can also use the lower-level RecastGraph.ReplaceTiles and RecastGraph.Resize methods if you prefer.

Thanks for the reply, will check the component and methods.

I did the same steps and got Unity crash again, here is the stack trace:

========== OUTPUTTING STACK TRACE ==================

0x00007FF86063933A (KERNELBASE) RaiseException
0x00007FFF9F2751C2 (Unity) LaunchBugReporter
0x00007FFF9EB6413F (Unity) EditorMonoConsole::LogToConsoleImplementation
0x00007FFF9EB64C3A (Unity) EditorMonoConsole::LogToConsoleImplementation
0x00007FFF9F7E97DD (Unity) DebugStringToFilePostprocessedStacktrace
0x00007FFF9F7E8B78 (Unity) DebugStringToFile
0x00007FFF9D78E0FD (Unity) MemoryManager::Allocate
0x00007FFF9D79883E (Unity) malloc_internal
0x00007FFF9D799BAA (Unity) BlockDoublingLinearAllocator::AllocateBlock
0x00007FFF9D799A9F (Unity) BlockDoublingLinearAllocator::Allocate
0x00007FFF9D1E76BC (Unity) UnsafeUtility::Malloc
0x00007FFF9D13B142 (Unity) UnsafeUtility_CUSTOM_MallocTracked
0x000001E4F668F05D (Mono JIT Code) (wrapper managed-to-native) Unity.Collections.LowLevel.Unsafe.UnsafeUtility:MallocTracked (long,int,Unity.Collections.Allocator,int)
0x000001E6476EEDAB (Mono JIT Code) Unity.Collections.NativeArray1<Pathfinding.Int3>:Allocate (int,Unity.Collections.Allocator,Unity.Collections.NativeArray1<Pathfinding.Int3>&)
0x000001E6476EEC93 (Mono JIT Code) Unity.Collections.NativeArray1<Pathfinding.Int3>:.ctor (int,Unity.Collections.Allocator,Unity.Collections.NativeArrayOptions) 0x000001E6476E658B (Mono JIT Code) [.\Packages\com.arongranberg.astar\Graphs\Navmesh\Voxels\VoxelRegion.cs:194] Pathfinding.Graphs.Navmesh.Voxelization.Burst.JobBuildRegions:Execute () 0x000001E6476B725B (Mono JIT Code) [.\Packages\com.arongranberg.astar\Graphs\Navmesh\Jobs\JobBuildTileMeshFromVoxels.cs:231] Pathfinding.Graphs.Navmesh.Jobs.JobBuildTileMeshFromVoxels:Execute () 0x000001E6476B3A5B (Mono JIT Code) Unity.Jobs.IJobExtensions/JobStruct1<Pathfinding.Graphs.Navmesh.Jobs.JobBuildTileMeshFromVoxels>:Execute (Pathfinding.Graphs.Navmesh.Jobs.JobBuildTileMeshFromVoxels&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int)
0x000001E6476B3B5A (Mono JIT Code) (wrapper delegate-invoke) Unity.Jobs.IJobExtensions/JobStruct`1/ExecuteJobFunction<Pathfinding.Graphs.Navmesh.Jobs.JobBuildTileMeshFromVoxels>:invoke_void_T&_intptr_intptr_JobRanges&_int (Pathfinding.Graphs.Navmesh.Jobs.JobBuildTileMeshFromVoxels&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int)
0x000001E6476B3716 (Mono JIT Code) (wrapper runtime-invoke) :runtime_invoke_void__this___intptr&_intptr_intptr_intptr&_int (object,intptr,intptr,intptr)
0x00007FFFA4AB68DE (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\mini\mini-runtime.c:3445] mono_jit_runtime_invoke
0x00007FFFA49F8404 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3068] do_runtime_invoke
0x00007FFFA49F84F0 (mono-2.0-bdwgc) [C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3115] mono_runtime_invoke
0x00007FFF9DF201F4 (Unity) scripting_method_invoke
0x00007FFF9DEF7FF3 (Unity) ScriptingInvocation::Invoke
0x00007FFF9DB25D54 (Unity) ExecuteJob
0x00007FFF9DB26C4D (Unity) ForwardJobToManaged
0x00007FFF9DB2246D (Unity) ujob_execute_job
0x00007FFF9DB21804 (Unity) lane_guts
0x00007FFF9DB24EF9 (Unity) worker_thread_routine
0x00007FFF9DD18FFD (Unity) Thread::RunThreadWrapper
0x00007FF86225E8D7 (KERNEL32) BaseThreadInitThunk
0x00007FF8631514FC (ntdll) RtlUserThreadStart

========== END OF STACKTRACE ===========

Looks like it potentially ran out of memory? Does that seem to fit.
Not sure why it would, though. The memory usage should not be unbounded.

My RAM could have been full at the time of building, but I have enough memory on my hard drive for that case.

BTW, NavmeshPrefab worked for me perfectly, thanks!