Course contentsShow
← Unreal Engine Game Development
Lesson 412 of 8806. AI, Navigation, and Decision MakingFree lesson

Managing Navigation Data for Procedural Levels

Students will learn to trigger runtime NavMesh updates to ensure AI can navigate through walls or floors generated during gameplay.

In this lesson, you will learn how to trigger runtime NavMesh updates to ensure your AI can successfully navigate through walls, floors, and platforms generated during gameplay.

When you build levels procedurally—such as spawning a dungeon layout or placing bridges at runtime—the static NavMeshBoundsVolume you placed in the editor is no longer sufficient. By default, the NavMesh does not automatically "know" about new geometry that appears after the level has started. To bridge this gap, we must configure the project to support dynamic updates and trigger them when our procedural generation finishes.

Enabling Runtime Generation

First, navigate to your Project Settings > Navigation Mesh and set the Runtime Generation property to Dynamic. This tells Unreal Engine to recalculate the navigation geometry while the game is running, rather than calculating it only once during build time.

Triggering Updates

Once the setting is enabled, you can force the NavMesh to refresh after spawning new actors. While the engine often handles this automatically for simple additions, complex procedural systems benefit from explicit control. You can use the Execute Console Command node (or the IConsoleManager in C++) to force a refresh if necessary:

// Force a NavMesh rebuild at runtime
GetWorld()->GetNavigationSystem()->Build();

However, a more performant approach for procedural levels is using Navigation Invokers. By placing an NavigationInvoker component on your AI pawns and setting the Runtime Generation to Dynamic, the NavMesh will only generate tiles around the AI. As your procedural level spawns new sections, the NavMesh tiles in that area will automatically invalidate and regenerate to account for the new floors or walls. This prevents the performance cost of rebuilding the entire map whenever a single door is added.

Always ensure that your procedurally spawned actors have their Can Ever Affect Navigation flag set to true in their component defaults. Without this, even with a Dynamic setting, the engine will ignore your new geometry entirely.

Key Takeaway: To navigate procedural geometry, switch your Project Navigation settings to "Dynamic" and use Navigation Invokers to ensure the NavMesh tiles update locally as new level elements are spawned.