
Welcome to C# Procedural Random Dungeon Generator in Unity 3D & Blender! In this course, you’ll learn how to create randomly generated dungeons using C# scripting and modular prefabs.
We’ll start by preparing Blender assets and importing them into Unity, then move on to C# scripting to generate seamless dungeon layouts. By the end of this course, you’ll have a fully functional procedural dungeon system that you can expand with your own custom rooms and features.
Follow along as we set up the Unity project that will serve as the foundation for this course. You’ll see exactly how the project is configured, ensuring everything is ready before we dive into procedural generation.
Learn how to configure Blender’s interface for a smoother workflow, adjusting key settings to improve efficiency and usability. These small tweaks will help you work faster and more comfortably.
Understand the process of exporting 3D models from Blender as FBX files and importing them into Unity. Learn how to configure External Materials, properly assign missing textures, and ensure your models are game-ready.
Get a detailed look at the modular room and hall models included in this course. Learn how to manipulate these assets in Blender and create new variations by following key design principles for seamless procedural connections.
Set up Unity prefabs using the imported FBX models. By the end of this lecture, you’ll understand how to convert your 3D models into reusable prefabs, ensuring a smooth workflow for procedural generation.
Learn how to configure deferred lighting in Unity to achieve optimal visual results. We’ll walk through creating a Light Prefab and properly placing lights within each room and hall, ensuring a well-lit and immersive dungeon environment.
Design a Connector Prefab that will serve as a pivot point between connected rooms and hallways. This prefab will feature a C# script using Unity’s OnDrawGizmos method to visualize connection areas with drawn outlines.
Assign the Connector Prefab to each open doorway within your rooms and halls. Learn how to use Unity’s vertex snapping to accurately place connectors, ensuring perfect alignment and reliable room rotations later in the course.
Understand the connection system in action through a step-by-step demonstration. See how rooms and halls accurately align using C# scripts, giving you a clear visual understanding of how the procedural system will work.
Write a C# method to generate the first room of the dungeon at runtime. Learn how to randomly rotate the Start Room in increments of 0, 90, 180, or 270 degrees to introduce variety.
Develop the logic to randomly select two connectors—one from the existing room (tileFrom) and one from the new room (tileTo). Ensure the script avoids selecting already-connected connectors, keeping the dungeon layout functional.
Now that connectors have been chosen, write the C# logic to seamlessly connect two rooms. Learn how to position and rotate prefabs to ensure proper alignment, forming a structured and expandable dungeon layout.
Define a new variable type and create a list of generated tiles using this type. This will allow us to track and manage all placed rooms and hallways within the dungeon.
Ensure that the dungeon generator correctly creates a linear path from the Start Room to the Exit Room, referred to as the Main Path. Organize public variables in the Inspector for better visibility and control over procedural settings.
Expand beyond the Main Path by adding branches. Learn how to select unconnected connectors along the path and randomly generate additional branches, allowing for more complex dungeon layouts.
Modify the color of room and hallway lights to aid in debugging. Assign yellow to the main path, green to branches, and cyan to the Start Room for an easy visual breakdown of the generation process.
Use a custom First Person Character Controller designed for prototyping. This lecture includes a Unity Package download containing the Prefab, scripts, and material setup for quick integration into your project.
Add Box Colliders to every tile in the dungeon. These colliders will be used to check for collisions in 3D space, ensuring that new rooms and hallways are placed without overlapping existing ones.
Implement collision detection for generated tiles. If a tile overlaps another tile, it will be destroyed and replaced with a new selection. Track the number of replacement attempts to allow for later backtracking when necessary.
When the number of replacement attempts exceeds a predefined limit, the generator will backtrack to find alternative connections. Learn how recursive backtracking allows the system to dynamically adjust and create more organic dungeon layouts.
Learn how to seal off unconnected passages by placing randomly selected prefabs at every unused doorway. This ensures that the dungeon remains fully enclosed, creating a polished and immersive environment.
Generate random door placements inside connector prefabs based on a predefined probability. Implement logic to ensure doors do not spawn in overlapping locations, maintaining a realistic and functional layout.
Animate doors in Unity to open and close smoothly on their pivot points. Set up an Animator state machine, define an isOpen boolean parameter, and allow the player to trigger door interactions when entering a collider zone and pressing a key.
Establish dungeon boundaries to prevent generation from exceeding the camera’s view. Configure boundaries to match the exact size and shape of the overhead camera, ensuring the procedural generation stays within limits while allowing for future customization.
Implement an enum-based Dungeon State system to track when dungeon generation is complete. This prevents unnecessary instantiations by ensuring that collision checks and backtracking finish before spawning enemies and objects.
Ensure random objects and items are spawned only after dungeon generation is fully complete. This prevents issues where objects spawn too early, avoiding unnecessary instantiations during tile placement.
Fix a rotation synchronization issue when spawning randomly generated room décor. Learn how to ensure spawned objects match the rotation of the room they are placed in, preventing incorrect orientations.
Learn how to place an Exit Room at the end of the main path while addressing a minor flaw in the existing generation logic. Ensure that the main path produces the correct number of rooms, and design a simple Exit Trigger Zone that allows the player to exit the level and generate a new random dungeon.
Access a zip file containing all scripts written throughout the course. This provides a quick reference for all the procedural generation logic, making it easier to review, modify, and expand upon in your own projects.
Here you will find more information about the instructor as well as important links to other courses.
Create endless, dynamically generated 3D dungeons using C# and modular assets in Unity!
This course will teach you how to build a procedural dungeon generator that assembles randomly connected rooms and hallways using a geomorphic system. Each room and hallway prefab seamlessly connects at 90-degree orientations along the north, south, east, and west entry points, allowing for limitless dungeon variations.
What You'll Learn:
★ Write a complete procedural dungeon generator in C# that dynamically assembles modular dungeon layouts.
★ Manipulate prefabricated rooms and hallways in Unity to create seamless, randomly generated interiors.
★ Export modular assets from Blender to Unity as FBX files and convert them into prefabs for procedural use.
★ Understand geomorphic dungeon generation and how to design prefabs that interconnect at fixed entry points.
★ Expand your dungeon system by designing custom rooms and hallways that integrate with your procedural algorithm.
This course is designed for intermediate Unity developers who want to add procedural dungeon generation to their projects. We’ll jump straight into writing structured, efficient C# code, focusing on how to create dynamic, ever-changing dungeons using a prefab-based geomorph system.
Whether you're developing rogue-like games, RPG dungeons, or randomized environments, this course will provide the tools you need to implement a powerful procedural generation system in Unity.
★ Enroll now and start building your own procedural dungeons in Unity today!