Guide
Culling and NavMesh
After a dungeon is generated, post-processors run on the same GameObject as the DungeonManager. Two of them are optional: DungeonCulling hides rooms the player cannot reach or see, and DungeonNavMeshPostProcessor bakes one NavMesh over the whole dungeon.
Post-processing order#
The manager runs every enabled post-processor, highest Priority first. Processors with the same priority keep their order on the component list, except that DungeonCulling always runs last among them.
| Component | Default priority | Role |
|---|---|---|
DungeonNavMeshPostProcessor | 0 | Bakes the NavMesh from the generated rooms. |
DungeonCulling | −100 | Hides rooms. Runs after the bake, so the bake still includes every room. |
Portal culling#
Culling hides rooms that are far away or behind doors that are closed. It does not change the dungeon itself. Removing the component restores the normal behavior.
-
Select the
DungeonManagerand click Add Culling Support. This addsDungeonCulling. -
Set Mode. It is Disabled by default, so nothing is hidden until you change it. Choose DisableRenderers for the cheapest option, or DeactivateRooms to switch the whole room off.
-
Set Reference Transform to the camera or the player. Culling is measured from this object.
-
Generate and play. Turn on Debug Draw to see visible rooms in green and hidden rooms in red in the Scene view.
modeDisabled, DisableRenderers, or DeactivateRooms default DisabledDisableRenderersstops rendering hidden rooms, and their scripts and physics keep running.DeactivateRoomsturns the room GameObject off, which also saves updates and physics. Switching many rooms back on at once can cause a short hitch.cullLightsbool default on- Also turns off the lights of hidden rooms. Used only in
DisableRenderersmode. maxHopsint default 4- How many doors away from the reference room a room may be and stay visible. 0 or a negative value means no limit.
occlusionToleranceint default 0- How many closed or locked doors a room may lie behind and stay visible. 0 hides everything behind the first closed door.
viewDistancefloat default 60- Rooms farther than this from the reference point are hidden, even when reachable. 0 or a negative value means no distance limit.
revealDistancefloat default 45- Distance at which a hidden room becomes visible again. It is smaller than
viewDistance, so rooms at the edge do not flicker. protectedNeighborHopsint default 1- Rooms this many hops from the reference room stay visible, even behind a closed door.
maxVisibleRoomsint default 0- Budget of visible rooms, kept by a deterministic score. 0 means no budget.
pollIntervalfloat default 0.25- Seconds between checks of the door states and the reference position. 0 checks every frame.
maxTogglesPerFrameint default 20- Rooms switched per frame, spread over frames to avoid spikes.
referenceTransform,referencePosition,useReferencePosition- The reference is the transform if set, otherwise the fixed position when
useReferencePositionis on, otherwise a registered local viewpoint or the main camera. With no viewpoint at all, every room stays visible. debugDrawbool default off- Draws the rooms and connections in the Scene view.
A connection is passable only when both of its doors are open and unlocked. Each mechanism above can be switched off in the Mechanism Toggles section, for example useMaxHops or useDistanceCulling.
To add your own rules, implement ICullConnectionRule (decides whether a connection is passable) or ICullRoomRule (forces a room visible or hidden). AcquireVisibility keeps a room visible while gameplay needs it. See the API Reference.
NavMesh#
The NavMesh post-processor bakes one NavMesh that covers the whole dungeon, on every floor, after each generation. It needs the AI Navigation package, version 2.0.13.
-
Select the
DungeonManagerand click Add NavMesh Support. This addsDungeonNavMeshPostProcessorwith its host and aNavMeshSurface. -
Check layerMask. Room floors, walls, and stairs must be on the layers in this mask. The default is the Default layer.
-
Generate. The baked NavMesh is ready when the generation is done. Use
logErrorsto see why a bake was skipped.
agentTypeIDint default 0, Humanoid- The agent type to bake for. Agent types are set in Project Settings › Navigation.
boundsPaddingfloat default 1- Extra space in meters on each side of the dungeon bounds.
layerMaskLayerMask default Default- Layers whose colliders are baked.
buildOnProcessbool default on- Bakes after each generation. Turn it off to bake yourself.
useDoorLinksbool default on- Adds a
NavMeshLinkat connections the NavMesh does not already cross, for example two floor areas that are not joined. linkEndpointInset,linkSearchRadius,linkWidthfloat default 0.3, 1.5, and 1.5- Where a link starts, how far it may move to reach the NavMesh, and how wide it is.
bakeConnectorsbool default off- Bakes temporary bridges across doorways instead of adding links. The NavMesh is then continuous through the doors. Overrides
useDoorLinks. connectorWidthfloat default 1.6, minimum 0.1- Width of the bridges. Keep it narrow enough to avoid false corner merges, but wide enough to survive the agent's erosion.
logErrorsbool default on- Logs why a bake cannot run: a missing host, no rooms, no colliders, or data it does not own.
Clear or regenerate the dungeon and the NavMesh is released first, then rebuilt for the new layout. A NavMesh that you bake yourself on the same objects is never touched.
Burst planner#
The Use Burst Planner option (useBurstPlanner on the DungeonManager, default off) runs the DFS placement search as Burst-compiled code.
- It is a separate implementation of the planner. The same seed can give a different valid layout than the managed planner. If a seed must keep its layout across builds, keep the same planner setting.
- Burst, Collections, and Mathematics are needed to compile the package even when the option is off.
Common mistakes#
- Culling does nothing. The mode is Disabled by default. Set Mode, and check that Reference Transform is assigned.
- Hidden rooms are missing from the NavMesh. Culling runs before the bake. Lower the culling priority, as described in Post-processing order.
- The bake fails with a read-access error. The room meshes do not allow read access. Turn on Read/Write in each model's import settings, or replace the mesh colliders with box colliders as the demo does. See Troubleshooting.
- Clicks miss the floor. Agents move only to points on the NavMesh. Check the bake in the Console, and that any roof or ceiling collider is off.