Getting Started
This is a quick getting-started guide for the dungeon generator. There is more info on the Details page.
How it works
The dungeon generator takes room prefabs and puts them together at connectors to build a dungeon.
Simplified generation flow:
- Spawn a starting room.
- Look at its connectors.
- For each connector, pick a room from a list.
- Place it so the connectors line up.
- Repeat until we hit the size limit or run out of valid spots.
Minimum requirements
To see anything generate, you need:
- At least one room prefab
- That room needs at least one connector
- A WeightedList that tells connectors which rooms they are allowed to spawn
- A DungeonGenerator in the scene that knows about your starting room
Step 1 - Make a basic Room
- Create a new GameObject in the scene (for example:
TestRoom). - Add the
Roomcomponent. - Build some simple geometry under it (floor, walls, whatever).
- Edit the
BoundingAreacomponent and make sure it roughly covers the whole room.
Turn it into a prefab once you’re happy with it.
Step 2 - Add Connectors
Connectors are where new rooms can attach.
- Inside your room prefab press "Add Connector" on the
Roomcomponent. This automatically creates a connector and adds it to the connector list. You can also do this manually by creating a GameObject, adding the connector component and adding it to the list on the room component. - Position and rotate it so its forward direction points "out" of the room (where the next room should appear).
- Add at least 2 connectors.
A room needs a minimum of one connector. But if a room only has one connector it will become a dead end since one connector will always be used as the entrance.
Step 3 - Create a WeightedList
To assign what rooms a connector can generate it needs a WeightedList that defines the rooms and the chance of it appearing. The WeightedList is a scriptable object that has a list of GameObjects and a weight associated to them.
- In the Assets window, create a new
WeightedListby right-clicking and chooseCreate -> VixDungeonGen -> WeightedList - Open it and add your room prefab with weight
1.
Step 4 - Hook it up to the connector
- Open your room prefab.
- Select the connectors.
- Assign the
WeightedListyou just created.
Now the connector knows which room(s) it is allowed to spawn.
Step 5 - Add the DungeonGenerator
- Create an empty GameObject in the scene (for example:
Dungeon). - Add the
DungeonGeneratorcomponent. - Set Starting Room to your room prefab.
- Set a max size / room count (for example:
20).
You can leave most other settings at their defaults for now.
Step 6 - Generate the dungeon
Press Generate
If everything is set up correctly, the generator will:
- Spawn your starting room.
- Use its connectors to place more rooms.
- Stop once it reaches the max size or can’t place more.
There are different settings for how the generation is handled. It can be spread out frame by frame or instant depending on the Generation Speed setting.
Where to go from here
A few ideas once the basics work:
- More room prefabs - corridors, T-junctions, bigger rooms, etc.
- Multiple WeightedLists - one for "normal" rooms, one for special ones.
- Tweak Connector Order - change how the dungeon grows (more branches vs long corridors).
- Add doors & WallPlugs between rooms - connectors can generate doors by adding a prefab to the connectors door list. Wallplugs can also be placed at unused connectors to plug holes. Since this is done per connection I suggest making your connectors prefabs.
For more info, check the Details documentation.