We may earn an affiliate commission when you visit our partners.
Course image
Billy McDaniel

Learn how to manipulate prefabricated rooms and halls with C# scripting to generate a unique randomly generated dungeon for your video games in Unity. Included in the course are a set of modular room and hall tiles which we'll use to create our dungeons. We'll start in Blender where we will export the individual mesh information to an fbx file and then import them into Unity and convert them to prefabs that we can use in our project. Next, we'll write a complete procedural C# script that uses those prefab tiles to generate intricate and endless variations of dungeons for your 3D games.

Read more

Learn how to manipulate prefabricated rooms and halls with C# scripting to generate a unique randomly generated dungeon for your video games in Unity. Included in the course are a set of modular room and hall tiles which we'll use to create our dungeons. We'll start in Blender where we will export the individual mesh information to an fbx file and then import them into Unity and convert them to prefabs that we can use in our project. Next, we'll write a complete procedural C# script that uses those prefab tiles to generate intricate and endless variations of dungeons for your 3D games.

The course is intended for intermediate-level Unity game developers who have a strong desire to create random environments in an interior-only series of rooms and hallways. We'll jump right into the code and write methods that perform specific functions while piecing everything together to produce the desired results.

You'll also learn to recognize the tile requirements which will be useful if you decide to go shopping for tiles to add to your collection or if you want to create your own.  This course is intended for video game developers with a desire for adding unpredictable environments to their games.

Enroll now

What's inside

Learning objectives

  • Random dungeon generation
  • Connecting rooms & halls at runtime

Syllabus

Initial Project Setup

Hello and welcome to "C# Procedural Random Dungeon Generator in Unity 3D & Blender"

In this course you'll learn how to manipulate prefabricated rooms and halls with C# scripting to generate a unique randomly generated dungeon for your video games in Unity.

Included in the course is a Blender file containing a set of rooms and halls that we'll use as modular tiles to build interior-only game environments.

I'll show you how to export from Blender and import to Unity, setup prefabs, lighting, and then how to connect those rooms and halls together using C# scripts at runtime. Then after the generation is complete, we'll create random items, enemies and more to further enhance the randomization.

By the end of this course, you'll have all the tools you need to create an endless supply of randomly generated dungeons. By adding your own room and hall designs, the possibilities are truely limitless.

So if you're ready to start learning how to create randomly generated 3D dungeons for your levels in Unity, then welcome to the course! I hope to see you in the next lecture.

Read more

This video allows students to see exactly how I setup the Unity Project which will be used for the remainder of the course.

Learn how the instructor has configured Blender to look a little nicer with a few options intended to enhance the work flow.

By the end of this lecture you will understand how to export your 3D meshes from Blender into a new FBX file and import it into Unity. I'll also demonstrate how to configure the files to use External Materials and show how to assign the missing textures to the Materials.

In this lecture we'll take a look at each individual model included with this course. By the end of this lesson you should be able to manipulate these models in Blender and make as many variations as you prefer. You'll also understand how to make new rooms and halls from scratch using the basic rules outlined in this tutorial.

In this lecture I'll spend time setting up each Unity Prefab. By the end of this video you will understand exactly how to create Prefabs in Unity using the mesh information available in your newly imported FBX files.

In this lecture I'll show you how to setup deferred lighting in Unity and then walk you through the process of creating a Light Prefab and then adding it to each individual room and hall.

In this lecture we'll design a special Prefab that will allow us to visualize the pivot point between two room's connected hallways which we'll refer to as Connectors. These prefabs will feature a special C# script that will use Unity's OnDrawGizmos method to DrawLines around the connector piece allowing our Prefab to show the outline of the connection area.

In this lecture we'll assign our new Connector prefab to each open doorway found within all of our rooms and halls. You'll learn how to use Unity's vertex snapping to place these Connector prefabs with 100% accuracy resulting in a reliable pivot point used for rotating rooms in opposite directions later in the course.

By the end of this lecture you should have a clear visual understanding of the technique that we'll use to connect any two rooms or halls together using a C# script. The visual demonstration takes you through the process step by step to ensure that you understand exactly how and why the script can accurately perform these transformations perfectly every time.

In this lecture, we'll create a method that generates the first room of our random dungeon. Learn how to randomly rotate the Start Room in increments of 0, 90, 180 or 270 degrees.

In this lecture we'll randomly determine which two connectors will be selected in the two rooms which we refer to as tileFrom and tileTo. The randomization process also prevents the script from choosing any connector which has already been connected.

Now that we have chosen which connectors need to be connected, we'll learn exactly how to connect them in our script.

Learn how to define a new type of variable and create a list of generated tiles using that new type of variable.

In this lecture we'll make sure our dungeon generator is creating all of the tiles needed to form a linear path from the start room to the exit room which we'll refer to as the main path. We'll also setup all of the public variables that we think we'll be using in the near future in the inspector so that things look a little more organized.

In this lecture I explain how to continue adding tiles after laying down the initial main path. You'll learn how to choose connectors from the main path which are not already connected and branch out in as many branches as you choose and each branch consisting of as many tiles as you prefer too.

In this lecture I'll modify the color of each room and hall light to use for debugging. By assigning all main path to yellow, branches to green and the start room to cyan, you'll be able to quickly identify what's going on as the generator builds the random dungeon.

In this lecture I'll be sharing a First Person Character Controller that I created for the purpose of Prototyping. Included in this lecture is a zip file containing a Unity Package containing the Prefab as well as the necessary scripts and material for the character controller.

This lecture focuses on adding Box Colliders to every tile in the game which we'll use to check a volume of 3D space for collisions when placing random tiles later on in the course. You'll learn how to AddComponent at runtime.

In this lecture we start checking for collisions with other tiles which have already been placed within the generated dungeon. If our tile does collide with something, we will need to destroy the tile and immediately choose a different tile to replace it. We also keep track of the number of times we attempt to do this so that we can backtrack later when the attempts counter reaches a predefined count.

In this lecture you'll learn how to recursively backtrack when the number of attempts exceeds the maximum number of attempts that you wish to allow. This backtracking procedure allows your generator to repeatedly retry connecting tiles and backtrack to rediscover different paths as it reaches out in random directions.

In this lecture you'll learn how to block off all unused passages in the generated dungeon with randomly selected prefabs designed to block these unconnected passages.

In this lecture you'll learn how to spawn doors inside of randomly selected connectors a certain percent of the time. You'll also learn how to detect if a door has already been spawned to prevent doors from spawning in the same general location.

In this lecture you'll learn how to animator a door in Unity to open and close on it's pivot point. You'll also learn how to setup the Animator's state machine, setup a boolean parameter called isOpen which can be changed at runtime anytime the player is standing inside a trigger collider zone and pressing a predetermined key bound for opening and closing doors.

In this lecture you'll learn how to set boundaries to your generated dungeon to help prevent your random generation from going outside the bounds of your overhead camera. These boundaries could be used for a variety of reasons but are also completely optional. You'll also learn how to setup these boundaries to the exact shape and size of your camera's view.

By the end of this lecture you will know how to create an enum that can tell you at which state your dungeon generation is currently in. Using this Dungeon State, you can find out when the generation has finished before you begin spawning items into the generated level. This will help you minimize the number of Instantiations by allowing all of the collision checking and backtracking to finish before populating your rooms and halls with randomly generated items and enemies.

In this lecture you'll learn how to wait for the generator to finish creating the dungeon before going ahead and spawning random objects into the dungeon. This will avoid instantiating items unnecessarily while the generating is still checking for collisions and deciding where to place all of its tiles.

Addressing a small problem with the code in the previous video. I'll show you how to synchronize the rotation of your randomly generated room decor with the rotation of the room it is being instantiated into.

In this lecture you'll learn how to place an Exit Room at the very end of the main path. I'll also outline a minor flaw in the existing code where the main path is not currently reliably producing the expected number of room tiles. By the end of this lecture you should not only be able to place an Exit where you want it, but we'll also design a simple Exit Trigger Zone which allows the player to exit the level and randomly generate a new level.

In this lesson I'll share all of the scripts that I have written for the entire course in one zip file.

Here you will find more information about the instructor as well as important links to other courses.

Traffic lights

Read about what's good
what should give you pause
and possible dealbreakers
Assumes familiarity with Unity and C# scripting, which allows learners to focus on procedural dungeon generation techniques
Uses Blender for creating modular assets, which is a common industry practice for game environment design
Focuses on interior-only environments, which may not be suitable for developers interested in outdoor or open-world generation
Teaches techniques for randomizing items and enemies, which enhances the replayability of generated dungeons
Emphasizes the creation of endless variations of dungeons, which is useful for roguelike or procedural content generation
Requires learners to manipulate prefabricated assets, which may limit creative control over the overall aesthetic

Save this course

Create your own learning path. Save this course to your list so you can find it easily later.
Save

Reviews summary

Procedural dungeon generation in unity & c#

According to learners, this course successfully delivers on its promise to teach procedural random dungeon generation in Unity using C#. Many students found the course content highly practical and directly applicable to their game development projects, enabling them to create unique and variable environments. The included Blender assets were also appreciated for providing a ready-to-use starting point. However, a notable challenge highlighted by reviewers is the complexity of the C# scripting, particularly the logic for collision detection and backtracking, which some found difficult to fully grasp. While the course is aimed at intermediate developers, some learners felt it required a strong prerequisite understanding of C# and Unity, potentially making it less accessible for those just stepping up to an intermediate level.
Covers essential export/import.
"Blender part was quick, just what's needed to get models into Unity."
"The focus is clearly on the Unity/C# side after the initial asset setup."
"Covers the necessary steps to get custom models into the project."
"Sufficient for integrating external assets, but not a deep Blender dive."
Includes Blender models & prefabs.
"The included room and hall models are very helpful for following along."
"Appreciated the ready-to-use prefabs and character controller."
"Saved time by having the assets provided, could focus on the code."
"Good starting assets to get the generator up and running quickly."
Directly usable in games.
"Can immediately use this in my game for creating varied levels."
"Highly practical skill for dungeon crawlers or similar genres."
"Gave me a valuable toolset for level design and replayability."
"The techniques taught are very relevant for actual game development."
Learn to generate random dungeons.
"I can now generate complex random dungeons for my game."
"The course delivered exactly what it promised - a working dungeon generator."
"Achieved the goal of creating random environments using the techniques shown."
"I successfully implemented the procedural generation logic in my own project."
Best for experienced C#/Unity users.
"Definitely need solid C# and Unity experience before taking this."
"Not for absolute beginners in scripting or object-oriented programming."
"Came in with some knowledge and still found the coding parts challenging."
"Assumes a certain level of comfort with complex scripting concepts."
Collision & backtracking code is challenging.
"The backtracking logic was particularly hard to grasp and required multiple watches."
"Struggled a bit with understanding the collision detection script flow."
"The code for handling overlaps felt complex and needed deep focus."
"Requires careful attention to understand the intricate script interactions."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in C# Procedural Random Dungeon Generator in Unity 3D & Blender with these activities:
Review Blender Basics
Refresh your Blender skills to better understand how the provided assets were created and how to modify them.
Browse courses on Blender
Show steps
  • Open Blender and review the interface.
  • Practice basic modeling techniques.
  • Export a simple mesh to FBX format.
Review C# Scripting Fundamentals
Review C# scripting fundamentals to prepare for the procedural generation scripts used in the course.
Browse courses on C# Scripting
Show steps
  • Review basic C# syntax and data types.
  • Practice writing simple scripts in Unity.
  • Review object-oriented programming concepts.
Unity in Action, Third Edition
Read this book to gain a deeper understanding of Unity and C# scripting.
Show steps
  • Read the chapters on C# scripting and Unity fundamentals.
  • Experiment with the code examples provided in the book.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Practice Unity Transforms
Practice manipulating Unity Transforms to solidify your understanding of object placement and rotation.
Show steps
  • Create a new Unity project.
  • Create several game objects.
  • Write scripts to manipulate their positions and rotations.
Create a Simple Room Generator
Start a small project to generate a single room with random props to reinforce the concepts learned in the course.
Show steps
  • Create a basic room prefab in Blender or Unity.
  • Write a C# script to randomly place props in the room.
  • Add lighting and test the generator.
Document Your Dungeon Generation Process
Create a blog post or video tutorial explaining your approach to procedural dungeon generation.
Show steps
  • Outline the key steps in your dungeon generation process.
  • Write a clear and concise explanation of each step.
  • Include code snippets and screenshots to illustrate your points.
  • Publish your content online.
Contribute to a Dungeon Generation Library
Contribute to an open-source dungeon generation library to share your knowledge and collaborate with other developers.
Show steps
  • Find an open-source dungeon generation library on GitHub.
  • Study the library's code and documentation.
  • Identify a feature or bug that you can contribute to.
  • Submit a pull request with your changes.

Career center

Learners who complete C# Procedural Random Dungeon Generator in Unity 3D & Blender will develop knowledge and skills that may be useful to these careers:
Game Developer
A career as a game developer involves creating and designing video games for various platforms. Game developers use programming languages and software development tools to bring game concepts to life. This course directly supports this career, because it teaches how to use C# and Unity, which are industry standard tools for game development. The course also focuses on procedural generation, a common technique used to create dynamic and varied game environments. The C# procedural script is a standout skill for a game developer. Learning how to manipulate prefabricated elements dramatically helps a prospective game developer.
Unity Developer
A Unity developer specializes in using the Unity game engine to create interactive experiences, including video games, simulations, and augmented reality applications. This course helps you become a Unity developer by directly teaching how to use Unity's features for level design. The course uses C# scripting to generate random dungeons, a common technique used in many games. By working with modular room and hall tiles, a Unity developer learns to optimize game assets and improve performance. Specifically, learning to export meshes from Blender into Unity and then converting them to prefabs is valuable.
Indie Game Developer
An indie game developer works independently or as part of a small team to create and publish video games. This course helps equip an Indie Game Developer with the skills to create a unique game. The procedural generation techniques taught in the course allows you to create a large amount of content with minimal effort, important for a single person or small team. You'll also be able to export your ideas from Blender into Unity to create the setting for the game. This skill can be a competitive advantage for an Indie Game Developer.
Level Designer
Level designers create the environments and layouts for video games. This course allows you to explore level design by teaching you how to generate random dungeons. You'll learn how to use C# scripts to connect rooms and hallways. This helps you understand how to create interesting and engaging environments for players. The focus on modular tiles also provides a foundation for understanding how to optimize level design for performance. The course teaches a level designer how to add unpredictable environments to their games.
Game Designer
A game designer conceptualizes and designs the rules, mechanics, and overall experience of a video game. This course helps a game designer learn valuable skills in level design and procedural generation. The ability to create random dungeons using C# scripting allows a game designer to prototype and experiment with different level layouts quickly. The focus on modular tiles also helps the game designer understand how to create efficient and scalable game environments. The game designer also finds value in the lessons about collision detection.
Virtual Reality Developer
A virtual reality developer designs and builds immersive experiences for VR platforms. This course helps prepare you to be a VR developer by teaching how to create interactive 3D environments in Unity. The focus on procedural generation allows the developer to create varied and unpredictable VR experiences. The ability to manipulate prefabricated rooms and halls with C# scripting is highly relevant. A virtual reality developer may also find value in the lessons about using Blender.
Augmented Reality Developer
Augmented reality developers create applications that overlay digital content onto the real world. This course may come in handy because it covers the creation of 3D environments in Unity, which are often used in AR applications. The procedural generation techniques taught in the course can be used to create dynamic and adaptive AR experiences. Learning how to connect rooms and halls at runtime is relevant for building interactive AR environments. The C# procedural script is also helpful.
Technical Artist
A technical artist bridges the gap between artists and programmers, developing tools and workflows to improve the art creation process in game development. This course may be useful for a technical artist because it covers topics such as exporting meshes from Blender to Unity, setting up prefabs, and using C# scripting for procedural generation. A technical artist uses these skills to optimize game assets and automate tasks. Learning about tile requirements in the course is particularly beneficial, teaching a Tech Artist how to effectively shop for or create assets.
Educational Game Developer
An educational game developer creates video games and interactive experiences designed for learning and training purposes. This course may support this career by teaching how to create dynamic and engaging 3D environments in Unity. The procedural generation techniques can be used to create varied and replayable learning scenarios. The focus on C# scripting allows the developer to implement interactive elements and track player progress. Learning to manipulate prefabricated elements in the course dramatically helps the educational game developer.
Simulation Developer
Simulation developers create software that simulates real-world environments or systems for training, research, or entertainment purposes. This course may be helpful by providing a foundation in procedural generation, which can be used to create dynamic and varied simulation environments. The focus on C# scripting in Unity allows you to implement complex simulation logic. The techniques for connecting rooms and halls at runtime can be adapted to simulate other types of spatial relationships.
3D Modeler
3D modelers create three-dimensional assets for video games, film, and other media. This course may give a 3D modeler skills related to game development pipelines. The course uses Blender to export individual mesh information to an fbx file, teaching a standard practice for importing 3D models into game engines. By understanding how these models are used in Unity, a 3D modeler can create assets that are optimized for real-time rendering. A 3D modeler finds the discussions about modular room and hall tiles to be instructive.
Software Engineer
Software engineers design, develop, and test software applications. While not directly related to traditional software engineering, this course helps software engineers explore procedural generation techniques. The focus on C# scripting and algorithm design exposes the engineer to different problem-solving approaches. The skills learned can be applied to other areas of software development where procedural generation is useful. The work on connecting rooms and halls at run time may be particularly useful.
Houdini Artist
A Houdini artist uses Side Effects Software's Houdini to create visual effects and 3D animations for film, television, and games. While Houdini is not directly covered, this course may be useful because it explores procedural generation techniques in a game engine context. Understanding how to generate random dungeons with C# scripting can inspire a Houdini artist to create similar effects using Houdini's node-based system. The discussions of using external assets may also be valuable. A Houdini artist typically needs a bachelor's and/or master's degree.
Unreal Engine Developer
An Unreal Engine developer uses the Unreal Engine to create games, simulations, and other interactive experiences. While this course focuses on Unity, the core concepts of procedural generation and level design may transfer to Unreal Engine. Learning how to generate random dungeons with C# scripting provides a foundation for understanding similar techniques in Unreal Engine's Blueprint visual scripting system or C++ scripting. An Unreal Engine developer may find value in the discussions about modular design.
AI Programmer
An AI programmer develops the artificial intelligence systems that control non-player characters and other dynamic elements in video games. This course may be useful because it touches on procedural generation, which can be combined with AI techniques to create more dynamic and unpredictable game worlds. The AI programmer could use this information to create new types of AI. The AI programmer learns how to manipulate prefabricated elements.

Reading list

We've selected one books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in C# Procedural Random Dungeon Generator in Unity 3D & Blender.
Provides a comprehensive guide to Unity development, covering C# scripting, game mechanics, and editor workflows. It's a useful reference for understanding the underlying principles of game development in Unity. While not specifically focused on procedural generation, it provides a strong foundation for understanding the Unity engine and C# scripting, which are essential for this course. This book is commonly used as a textbook at academic institutions.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser