[This is preliminary documentation and is subject to change.]
See the NMGenParams documentation for information on the standard configuration settings.
Controls and Target Assignment
The upper portion of the inspector contains the main build controls and build target.
The bake target is the asset that will get the result of the build. (The navigation mesh.) Any ScritableObject that implements the INavmeshData interface can be used. The normal target will be a CAIBakedNavmesh asset. Note that this is a navigation asset, not an NMGen asset, so it can be distributed as part of the project compile and be referenced by scene components.
There are two types of builds. A standard build is performed directly from the inspector and will run a foreground build of the entire navigation mesh. (Can't do anything else in the Unity editor until the build is complete.) The advanced build provides extra debug options, background build capabilities, and the ability to partially rebuild multi-tile navigation meshes. The advanced build uses a special editor window for the build.
The Log Mesh State button will log the current state of the build target to the console. (Polygon count, bounds, etc.)
The Build & Bake button will run a full build and bake of the navigation mesh in the foreground using the current scene as the input source. (There will be a warning at the top of the inspector if the current scene is not the same as the last input scene.)
If Trace is enabled, then detailed trace messages will be sent to the console. This is useful for debugging the build.
This section will not be avaiable if the build type is set to advanced.
The configuration section contains the standard NMGen confiugration settings plus a some Unity specific options.
The very first NMGen configuration settings you should take a look at are the Agent Settings. Most other settings are derived, at least in part, from these. Unlike the NMGenParams core class, these agent settings are in world units, not cell units. Set the values based on your agent maximums. (Maximum height, maximum radius, etc.)
The next settings you'll want to take a look at are the Resolution and Tile Settings. You can derive these yourself with the help of the NMGenParams documentation. But if you've already set up the scene you can use the Derive button to get a good starting point. The values will be derived based on a combination of the agent settings and bounds of the input geometry.
A Tile Size of zero results in a single tile mesh.
There are various toggle options in the Advanced configuration section. These will automatically add NMGen processors to the build as follows:
- Ledges Not Walkable -> FilterLedgeSpans
- Low Height Not Walkable -> FilterLowHeightSpans
- Low Obstacles Walkable -> LowObstaclesWalkable
- Apply Poly Flag -> ApplyPolygonFlags (Flag: 0x01)
If you don't need a lot of height detail in your navigation mesh you can uncheck the Include Detail Mesh option. This will make the final navigation mesh more memory efficient.
The Clean button can be used to round values to more reasonable values. (E.g. 0.2929384839 to 0.29)
The Reset button will reset the NMGen configuration to its original default values.
The input configuration contains the scene query and processor asset assignments.
The assets assigned in this section can be created using menu items founds under CritterAI -> Create NMGen Assets. Note that some assets are effectively singletons with no configuration. In such cases there is no need to create more than one per project; and the inspector won't let you add them twice to the same build.
It is perfectly fine to share scene query and input processors between multiple NavmeshBuild assets.
The most common scene query is TagSceneQuery. The scene query is optional. If none is provided then the search will be global. E.g. All MeshFilters in the scene, all terrains in the scene, etc.
There must be at least one input processor for the build. For simple builds this is usually a compiler. The most commonly used compiler is MeshCompiler. You can add as many processors as you wish. The processors will be run in ascending priority. This is especially useful for area assignment since it allows higher priority areas to overwrite lower priority areas.
The inspector won't let you add the the same input processor asset to a build twice.
The Auto-Clean option is used to automatically clean up invalid triangles in the input geometry. Sometimes modeling programs can let invalid triangles slip in; triangles that are no problem for the renderer but cause problems for NMGen. For example, triangles that contain the same vertex twice will be removed.