In this lesson, you will learn how to drastically reduce memory usage in large-scale environments by using Navigation Invokers to generate NavMesh data dynamically around your AI agents.
The Problem with Static NavMeshes
In a large, open-world game, generating a NavMeshBoundsVolume that covers the entire map is incredibly expensive. It consumes vast amounts of memory and increases build times significantly. Furthermore, if your AI agents are only ever in a small portion of the map at any given time, 90% of your generated navigation data is essentially dead weight.
Implementing Navigation Invokers
Navigation Invokers solve this by shifting the paradigm from "global generation" to "local generation." Instead of one massive, static mesh, you tell the engine to generate navigation data only within a specific radius around an actor.
- Project Settings: Go to Project Settings > Navigation Mesh and set the
Runtime GenerationtoDynamic. - Disable Static Generation: Uncheck
Generate Navigation Automaticallyin your globalNavMeshBoundsVolume(or remove it entirely). - Setup the Actor: Add a
NavigationInvokercomponent to your AI Pawn or Controller. - Configure the Radius: Inside the
NavigationInvokersettings, define theGeneration RadiusandTile Generation Radius. These values determine the area around the actor where the NavMesh will exist.
As your AI moves through the world, the NavigationInvoker acts as a moving "bubble." It automatically builds and discards navigation tiles in real-time as the actor travels. If an actor leaves a zone, that NavMesh is purged from memory, keeping your footprint lean and performant.
Strategic Implementation
This is particularly effective for AI roaming in large environments. You can trigger tile generation only for agents that are "active." For instance, you might choose not to add a NavigationInvoker to every single background NPC, reserving them only for high-priority agents that actually need to calculate complex paths. This ensures the CPU isn't overwhelmed by constant, unnecessary mesh rebuilding.
Key Takeaway: Navigation Invokers turn your NavMesh into a dynamic, "just-in-time" system, ensuring that navigation data is only loaded and processed in the immediate vicinity of your AI agents.