Skip to content

Pathfinding: Overview

Once your dungeon layout is generated by DunGen, a crucial next step for many games is enabling Artificial Intelligence (AI) agents, such as enemies or NPCs, to navigate the space effectively. This requires a pathfinding system to analyze the generated geometry and create navigation data (like a NavMesh or pathfinding graph).

DunGen itself focuses solely on generating the dungeon's layout and structure; it does not include its own pathfinding logic. However, since the dungeon is created dynamically at runtime, static pathfinding data baked in the editor won't work. The navigation data needs to be generated or updated after the DunGen layout is complete.

DunGen addresses this by providing Integration Adapters. These are components you add alongside your Runtime Dungeon component. They hook into DunGen's post-processing phase and automatically trigger the necessary actions in your chosen pathfinding system (like baking a NavMesh or scanning a graph) once the dungeon geometry is finalized.


Supported Pathfinding Systems

DunGen comes with built-in adapters for several popular pathfinding solutions:

  • Unity NavMesh Components: Integration with Unity's modern, component-based NavMesh system (requires separate package installation from Unity). Supports runtime baking and linking across tiles. Includes a 2D variant.
  • A* Pathfinding Project Pro: Support for the Recast NavMesh in Aron Granberg's powerful third-party pathfinding asset. Enables runtime graph scanning after generation.

Custom Integrations

If you are using a different pathfinding system not listed above, you can create your own integration:

  • Custom Adapters: Learn how to write your own adapter script by inheriting from DunGen's BaseAdapter class. This allows you to trigger any custom logic needed by your pathfinding solution during DunGen's post-processing phase.

Handling Doors

A common requirement is handling doors that open and close, dynamically changing path availability. The specific integration pages detail how each adapter typically handles doors, often relying on DunGen's built-in Door component to toggle walkability in the pathfinding data.


Please navigate to the page corresponding to the pathfinding system you are using in your project for specific setup instructions and details.