Skip to content

Core Concepts: Tiles & Tile Component

What is a Tile?

Tiles are the fundamental building blocks of your dungeons. Think of them as reusable room prefabs, corridor segments, or any distinct piece of level geometry that DunGen will piece together.

You design these Tiles visually within the Unity editor, just like any other prefab. DunGen's power comes from how it connects these pre-designed pieces based on rules you define.

The Tile Component

The Tile component provides DunGen with specific metadata and allows you to override certain global generation settings on a per-tile basis.

Tile Component Settings

Here are the key settings available on the Tile component inspector:


Allow Rotation

  • Functionality: If checked, DunGen is allowed to rotate this Tile 90, 180, or 270 degrees around its Y-axis (up-axis) to match the orientation of an adjacent Tile's doorway.
  • When to Uncheck: You should uncheck this if your Tile:
    • Is designed for an isometric or fixed perspective where rotation would break the visual style.
    • Has a specific "back wall" or orientation that must be preserved.

Global Override

The Dungeon Generator component has a global Allow Tile Rotation setting. If you need to disable rotation for all tiles, use the global setting instead of configuring each tile individually.


Repeat Mode

  • Functionality: Determines how DunGen handles placing multiple instances of this specific Tile prefab within a single dungeon layout.
  • Options:
    • Allow: No restrictions. All repetition is allowed.
    • Disallow Immediate: This Tile can appear multiple times in the dungeon, but never directly connected to another instance of the same Tile prefab.
    • Disallow: This Tile prefab can appear at most once in the entire generated dungeon layout.

Use Disallow Carefully

If you use Disallow mode, ensure you have enough unique Tile prefabs available in your Tile Sets for the configured dungeon length. Otherwise, DunGen might fail to generate a valid layout if it runs out of non-repeating tiles.

Global Override

The Dungeon Generator component has a global Repeat Mode override setting that applies to all tiles.


Override Automatic Tile Bounds

  • Functionality: By default, DunGen calculates the physical boundaries (an Axis-Aligned Bounding Box - AABB) of a Tile based on the Renderers and Colliders within its hierarchy. Checking this box allows you to manually define the bounds used for collision detection during generation.
  • When to Use: Useful if the automatic bounds calculation isn't accurate for your Tile's effective space, perhaps due to complex shapes or invisible helper objects affecting the bounds.

Note

The Fit to Tile button can be used to match the overridden bounds to what DunGen's automatic calculation would be, giving you a starting point for manual adjustments.


Override Connection Chance

  • Functionality: Allows this specific Tile to override the global Connection Chance set in the Dungeon Flow asset. This chance determines the likelihood of DunGen connecting two otherwise unconnected doorways that happen to overlap spatially (potentially creating shortcuts or loops).

Interaction

If two tiles with overlapping doorways both have this override enabled, the lower of the two percentage chances will be used.


Entrance / Exit Doorways

  • Functionality: You can optionally designate specific Doorway GameObjects within this Tile as the required entry or primary exit points.
  • Entrance:
    • If set, DunGen must connect to this specific Doorway when placing this Tile. The Tile can only be entered through this doorway.
    • If unset (None), DunGen can enter the Tile through any available Doorway.
  • Exit:
    • If set, DunGen must use this specific Doorway as the first point of exit when pathing continues from this Tile.
    • If unset (None) or once the exit is already in use, DunGen can exit the Tile through any available Doorway.
  • Use Cases: Essential for controlling flow within complex tiles or ensuring specific placements, such as positioning a locked door (related to the Lock & Key System) correctly at the entrance of a boss room.

Tags

  • Functionality: Allows you to assign one or more custom tags to this Tile.
  • Purpose: These tags are used by the Tile Connection Rules system (configured in the Dungeon Flow asset) to allow or deny connections between specific types of tiles (e.g., preventing two "Corridor" tagged tiles from connecting directly). Tags are extremely versatile and can be used for any number of purposes in your own code.

By understanding and utilizing these Tile component settings, you gain significantly more control over how your individual Tile prefabs behave and integrate into the final generated dungeon layout.