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.
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.
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.
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.
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.
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.