Skip to content

Getting Started: Doorways

Creating a Doorway

Now we need a way to tell DunGen where we want our doorways to be. To do this, we'll create another empty GameObject and call it “Doorway”. Be sure to parent it to your tile GameObject. Now we'll add a Doorway component to our new doorway: Add Component > DunGen > Doorway

Doorway Placement

The doorway should be placed on the very edge of the tile with its local Z-axis (shown by the light blue line in the editor) pointing outwards.

Working in 2D?

Make sure the door is correctly oriented to match your up-direction. The green line should point upwards.

Can't see the doorway?

If the doorway outline isn't visible, check that Gizmos are enabled in the Scene view. Look for this button: Gizmos Button. You may also need to expand the dropdown next to it and make sure the 'Doorway' checkbox is checked

Don't worry if the outline doesn't match the shape or size of your doorway. For the purpose of this tutorial, all that matters is that the doorway is centered correctly.


Doorway Blockers

Right now, DunGen can connect Tiles using your doorway—but unused doorways would leave visible gaps in the dungeon walls. To prevent this, we’ll use Blockers to automatically fill in any unused doorways.

A blocker can be anything that visually closes off a doorway: a wall, debris, furniture, or even a sealed door.

Doorway Blocker

  1. Create a new GameObject with a wall mesh (or whatever fits your aesthetic).
  2. Position it to block the doorway.
  3. Parent this blocker to the Doorway object.
  4. In the Doorway component, expand the Blockers section.
  5. Drag your blocker GameObject into the Scene Objects list.

Now, when a doorway isn’t used during generation, the blocker will be shown. If the doorway is connected to another room, DunGen will automatically hide the blocker.


Reusing Doorways

For easy reuse of our doorway, we can make it a prefab by dragging the GameObject into our project window. Now, any changes made will be reflected wherever we use our doorway prefab.

Once that's done, you can easily duplicate and reuse it for each of the remaining door gaps in your room:

  • Drag the prefab into the scene, or
  • Select an instance and press Ctrl+D to duplicate it

Place a doorway at each of the gaps you left earlier.


Recap

At this stage, you should have:

  • A simple room Tile
  • A doorway placed at each entrance
  • Each doorway containing a Blocker to fill in unused paths

Here's what your setup should look like:

First Doorway - End Result