RANDOM DUNGEON GENERATION - EASY UNITY TUTORIAL - #3

  Рет қаралды 110,468

Blackthornprod

Blackthornprod

Күн бұрын

In the final episode of the RANDOM DUNGEON GENERATION tutorial series we will fix some quirks, add an exit room and dream up ways on expanding the system !
By the end of the video you will have a complete, working random dungeon generation that you can then use in your own game projects !
------------------------------------------------------------------------------------------------
SUPPORT ME : / blackthornprod
------------------------------------------------------------------------------------------------
DOWNLOAD PROJECT VIA GITHUB : github.com/Bla...
------------------------------------------------------------------------------------------------
Here is the LINK to my TWITTER : / noacalice
Here is the LINK to the DISCORD : / discord
Here is the LINK to the ENTIRE SERIES : • RANDOM DUNGEON GENERATION

Пікірлер: 445
@IeyasuTokugawa1
@IeyasuTokugawa1 5 жыл бұрын
If I may add, you don't need to run a for loop to spawn the boss. all you need to do is this: Instantiate(boss, rooms[rooms.Count-1].transform.position, Quaternion.identity); this basically does the same thing the for loop does, but without burdening the game with an unnecessary process. Great video btw, helped me make a dungeon generator for the first time.
@ACR995
@ACR995 Жыл бұрын
Where do you put this function
@Silberdragon1
@Silberdragon1 Жыл бұрын
@@ACR995 in Roomtemplates where the for-loop is instead of the for loop
@jatyman3017
@jatyman3017 Ай бұрын
It does have a small chance of putting the boss under the closed room however.
@xLeopanther
@xLeopanther 5 жыл бұрын
Just an idea: For the case of two spawn points colliding, instead of spawning a closed room, you could spawn a 'secret room' instead. It still makes it look like the walls are closed off, but it has breakable walls to allow entry if the player tries to destroy the wall (with whatever mechanics the game has). The secret room itself could shoot out raycasts to determine in which directions it should have breakable or unbreakable walls (if the Raycast hits another room, breakable. Else unbreakable. So you can't break open a wall where there is no room on the other side).
@chaosmastermind
@chaosmastermind 2 жыл бұрын
I'm guessing that is how binding of Isaac does it and why those secret rooms are always between two rooms like that. They did exactly what you said instead of putting a wall. Genius way of making use of a weird bug and turning it into a feature.
@douglasmatos7652
@douglasmatos7652 3 жыл бұрын
After 8 hours trying to do that works I finally do this works great! For everyone who gets null refeer, pay attention on colliders....all them must have kinematic...and on the center of closed room I've put a spawnpoint with no direction (zero)...and the tag "SpawnPoint"... For the Destroyer I put the script RoomSpawner, and set the direction to "zero" too...And after this your code will works...
@1upGAMeR200
@1upGAMeR200 3 жыл бұрын
Now it works, thanks :D
@mineninja2444
@mineninja2444 Жыл бұрын
thank you so much that fixed my one bug!
@MilkyGamesOfficial
@MilkyGamesOfficial Жыл бұрын
it worked but i had to make a 2d renderer empty with those as well as the 2d versions
@petesavage5846
@petesavage5846 4 ай бұрын
Thank you
@ТарасДубинин
@ТарасДубинин 5 жыл бұрын
There's a problem here. Look at 4:49, the rooms on top and top-left of the starting room have a door and a wall facing each other. Two ways to fix this: 1) A collision of spawners should add a condition (an extra required door) to the "surviving" spawner (this will also require some rewriting for room-type arrays); 2) After the level is generated, run through it again with a check to locate and remove such mismatches (turn them into doors, or walls, or random).
@TheRafler
@TheRafler 3 жыл бұрын
How would you do the first option? I've tried with colliders in doors and walls but to no avail :(
@수현정-n4e
@수현정-n4e Жыл бұрын
Hello, I also found a problem and fixed it and posted a comment. There may be some shortcomings, but I'm glad to see you had the same concerns, so I'm leaving a reply.
@nxcztrx6555
@nxcztrx6555 Жыл бұрын
For anyone struggling with walls that should be opened, the easiest option, is to duplicate the spawnpoints, rename it to DoorOpeners (FOR EXAMPLE), and position them in the center of the opened way, then create a script that contains an "OnTriggerEnter" that destroys the gameObject and assign it to all of the DoorOpeners. If you do this, all the ways that should be opened will be opened. If you have a floor and it destroys with the DoorOpener, you can reposition the cube in order to avoid destroying the floor or tagging the walls that should be opened and then compare the tag in the "OnTriggerEnter" to destroy only that gameobjects. Hope it helps.
@knack3381
@knack3381 3 жыл бұрын
One issue i encountered (and fixed) in my project is that I added three and four way rooms, and this essentially opened the floodgates to infinite rooms being spawned. In the example video, he only has rooms with 2 exit or less exits. His script essentially makes levels that have four dead ends, and the reason they end up as big as they are is because the two exit rooms are more common (each direction has two corners and a hallway). So the probability after the initial spawn (4 paths): 1/4: 1 exit (-1 path, dead end) 3/4: 2 exits (0 paths. these just delay the time it will take for a new path to be added/removed) 0/4: 3 exits (+1 path) 0/4 (aside from the initial spawn): 4 exits (+2 path) Adding rooms with 3 or 4 exits into the array throws off this balance because a room with 3 exits will have 3 variants, just like the 2-exit rooms. This creates an issue since the game will basically throw off the odds of ending a path in favour of creating a new one. Now the odds become: 1/8: 1 exit (-1 path) 3/8: 2 exits (0 path) 3/8: 3 exits (+1 path) 1/8: 4 exits (+2 paths) This caused an infinite loop and a crash because the game would just keep adding more and more paths onto itself, and create an infinite number of rooms. Even if there was any hope of the 1/8 chance for a single exit to work, a room with 4 exits has the same odds of spawning. If you want to implement rooms with 3 or 4 exits into the game, then the game will not spawn infinite rooms if you increase the odds of rooms with 1 and 2 exits to spawn. You can do this by adding duplicates into the arrays on the Room Templates GameObject. My levels ended up much more reasonable once the odds looked something more like this: 3/16: 1 exit (-1 path) (using 3 dupes) 9/16: 2 exit (0 path) (3 dupes) 3/16: 3 exit (+1 path) (0 dupes) 1/16: 4 exit (0 dupes, i also started using this as a substitute for the "wall" room with 0 exits that was used in the video) This could be customized, anything goes as long as its not nearly as out of balance as the original. If the odds of 1 room spawning are too high, then you won't have a level, and if the odds of a branching path are too high, then it can crash the game. I hope this breakdown at least helps somebody, cause this is more of a probabilities and logistics issue than some kind of direct coding error or missing component. All you need to know is that putting duplicates in the Room Templates arrays is kosher.
@crystalmav2931
@crystalmav2931 2 жыл бұрын
Hey Knack, adding 3 and 4 exit rooms works perfectly with your settings, the only problem I'm getting is, that I often get walls and doors right next to each other (like 4:49). Did you find a solution for this by any chance?
@DominadorJrPablo
@DominadorJrPablo 6 жыл бұрын
can you also create tutorials for randomized interiors? also pathfinding for travel between different rooms?
@DoomVisuals
@DoomVisuals 3 жыл бұрын
for example you take a spawn point for every place you want to palce furniture and do the same thing that you did in this tutorial, assign more furniture components to the same spawn point and make a script to spawn a random one of them. If you have a drawer that's small and another drawer that taller, just put it in a game object and make every game object of every furniture at the same level so there will be no problem in their positioning.
@luciorojas4278
@luciorojas4278 4 жыл бұрын
Infinite Rooms and OFF-centered update: I had the same issue as some people spawning infinite rooms and crashing unity. also the rooms being created off-centered. What fixed it for me : I created the rooms from scratch carefully placing the 2D colliders (walls), this fixed both of previous stated errors, it seems like the rooms were colliding with eachother and not being properly centered and not having the colliders placed correctly. I recommend everyone creating carefully the rooms and the 2D colliders, everything centered and the prefabs positions at 0,0,0. hope it helps someone
@Thobinambours
@Thobinambours 6 жыл бұрын
Really cool serie, very useful. You made it comprehensible for C# beginner like me :) Keep up the good work !
@gamingtotdemaxi
@gamingtotdemaxi 4 жыл бұрын
For anyone getting the "NullReferenceException: Object reference not set to an instance of an object" Error, just add the RoomSpawner script to your Destroyer, and put the openingDirection at 0
@Christian-dd2qm
@Christian-dd2qm 3 жыл бұрын
doesn't make a difference here
@lukejsimmons
@lukejsimmons 3 жыл бұрын
Thank you!!! Spent so long trying to figure this out!
@spookycafe
@spookycafe 2 жыл бұрын
Thanks!!
@laxmax85
@laxmax85 2 жыл бұрын
Thanks that fixed it!
@CelsoFilho3D
@CelsoFilho3D 2 жыл бұрын
Thanks!!!!
@onetupthree
@onetupthree 6 жыл бұрын
I've only watched this series from your channel and I'm already liking it very much!! Your voice and explanations are clear. Keep up the good work! :) * subscribed!!
@Blackthornprod
@Blackthornprod 6 жыл бұрын
Thanks so much for the sub :) ! I'm really glad to hear you enjoyed the content ! Stay tuned !
@priyajvora1824
@priyajvora1824 6 жыл бұрын
Thanks, that was a good short series for randGen
@PhilDeveloper
@PhilDeveloper 4 жыл бұрын
You don't need the destroyer script you can just add the room spawner to the empty game object in the middle and set the opening direction to zero
@davidsimanovic8104
@davidsimanovic8104 4 жыл бұрын
thank you
@PhilDeveloper
@PhilDeveloper 4 жыл бұрын
@@davidsimanovic8104 np!
@수현정-n4e
@수현정-n4e Жыл бұрын
4:49 Hello, I watched a video in Korea. I found that the connection was not possible because the passage was blocked. So I created a new script "RefixMap" And I created a GameObject in the middle of LB, LR, LT, BT, RT, and RB."refix" Collider2d and rigidbody2d in new GameObjects was applied, "RefixMap" was applied. The new script uses OntriggerEnter2d to check the name of the SpawnPoint that collides with "refix" and the number of collisions. If there is only one collision, the SpawnPoint will create a removed L, B, T, R. And the original room is destroyed by calling the parent. Destroys the object on 2 or 3 collisions. When creating a new room To modify the index number of the original room in the list in Templates, add an int to "AddRoom" and then use Count to find the length of the int added after rooms.Add(). And get the length from "RefixMap" templates.rooms[addroom.roomsindex - 1] = Instantiate(Room to create, transform.position, Quaternion.identity); Just do it. Here I've changed the bool RightWay to True if the SpawnPoint's name is associated with "L" to create a rightroom that is True. And it is executed after all spawnpoint actions are finished with Invoke("", 4.1f); Translated using Google Translate. Even if it's weird, I'd appreciate it if you read it carefully. Also, if there is something missing, please let me know in the comments.
@averywhitted358
@averywhitted358 2 жыл бұрын
Don't worry about making the Destroyer object just copy a Spawn Point, move it to the center of the room, change the openingDir to 0 and set Spawned to true in the inspector before runtime. 👍
@Janox_Zockt
@Janox_Zockt 2 жыл бұрын
Which Version off Unity have you used?
@aurorasabyss6534
@aurorasabyss6534 4 жыл бұрын
to anyone who gets the issue at 2:08 where the 'closed wall'' spawns in the starting room you need to add a '2d box colider' to the 'closed wall'' and make it a trigger
@louislemur
@louislemur 4 жыл бұрын
jesus christ i read your comment 4 times, in the span of 6 hours. And at the 5. time i got it! Thank you so much, much love
@louislemur
@louislemur 4 жыл бұрын
i had a 3D box collider
@aurorasabyss6534
@aurorasabyss6534 4 жыл бұрын
@@louislemur all g
@loukasavgeriou8634
@loukasavgeriou8634 4 жыл бұрын
i think your comment is really helpfull but can you please explain it again, cause i have some trouble understanding it. thank you
@Maxainn
@Maxainn 4 жыл бұрын
@@loukasavgeriou8634 The same happend to me, its because we are referencing in Destroyer a "OnTriggerEnter2D" and the closed wall has a 3D Box collider called "Box Collider" witch is not the same as "2D Box Collider" "OnTriggerEnter2D" is referencing at that one.
@rorymaclennan8796
@rorymaclennan8796 6 жыл бұрын
this is an incredible video, I learnt so much and I love all of your content. Keep up the good work.
@angelicus-9307
@angelicus-9307 3 жыл бұрын
anyone have tips on how to or where to learn more about. 1. Making it so you dont see the next room until you open the door (ex have a roof over or something until you open the door) 2. Add random objects(assets?) like barrels and grass and stuff like that, in the room to make each room look different. 3. Randomly decide if a room has monsters, treasure, npc or is "empty". 4. How to make the rooms spawn closer to the room that spawns it. So that the walls overlap. (i mean, i could "just" change the spawnpoints and move them closer. but that would mean making destroyers for every door. Just wondering if there is some easier way. Guess i could make each room a little bigger, and that way make em spawn into eachother 5. How can i stop the destroyer? if i walk on with the player character, it destroys that object as well
@JessePrice
@JessePrice 5 жыл бұрын
In case anyone follows along and the wall room keeps spawning in the middle another method to get rid of it is to add && transform.position.x != 0 && transform.position.y != 0 to the if check when you are spawning rooms ie if(collision.GetComponent().spawned == false && spawned == false && transform.position.x != 0 && transform.position.y != 0) in room spawner.... Not the most optimized route but should be fine as long as you aren't spawning a thousand rooms as long as your starting room is positioned at 0,0,0
@nicholaswetta6644
@nicholaswetta6644 6 жыл бұрын
Thanks for this tutorial! I struggled with rooms that would spawn with a doorway facing the wall of an already spawned room and it looked sloppy. I ended up making a list of these “final rooms” that had a doorway that wasn’t accessable. On my AddRoom script I created a variable that contains the openingDirection from the spawn point that created the room. After the same timer that normally triggers a boss, I go through the “final rooms” list and replace each room with rooms that have a single door, and I know which direction the room should face by looking at the openingDirection variable that got copied from the spawner that made the room.
@elxungaka
@elxungaka 6 жыл бұрын
How do you know what are the final rooms? I try so much things but I'm stucked. Thanks ^^
@SociopathDev
@SociopathDev 5 жыл бұрын
can you give an example? its interesting
@dmencoStudio
@dmencoStudio 3 жыл бұрын
How do you know which are the final rooms? Can you help us?
@GianniRivero
@GianniRivero 6 жыл бұрын
Funny how this came out right after I programmed the exact same thing, and even further how similar they are :D! If anyone needs help adding more complex functionality such as different room types or fog of war or anything else LMK.
@nickgerhold3176
@nickgerhold3176 6 жыл бұрын
how would you do different room types, or different room sizes?
@GianniRivero
@GianniRivero 6 жыл бұрын
So the way I did this was using a random number gen I decided the type of room from a array of types and set that as the type when it spawns. If you want a specific number of that room or a cetrain ratio you can subtract from the amount you want till its zero and then randomize again till you get a different type. I actually just finished a version of this which worked really well. If you have anymore questions you can message me on discord Dwarvenspaghetti#4307
@pablorozo7736
@pablorozo7736 6 жыл бұрын
Hey, can u helpme? For some reason i get some doors in the direction of walls, I do not know why this happens? Any help I would appreciate it!
@GianniRivero
@GianniRivero 6 жыл бұрын
Look at his code at 1:17, if that doesn't work then lmk and I can help you further.
@pablorozo7736
@pablorozo7736 6 жыл бұрын
I already try, I show you what happens, I attach an image with one of the possibilities of doors to walls, it does not always happen but the ideal is that it does not happen, thank you! ibb.co/gvo96z
@christianbucal6933
@christianbucal6933 Жыл бұрын
I was shocked at 1:10. I almost screamed.
@youtuberdisguiser6075
@youtuberdisguiser6075 5 жыл бұрын
I'd suggest to first spawn blank rooms and then later turning those blank rooms into the desired rooms. Starting point than you let white sqaures spawn at the site and once no new squares are spawning you turn them into the desired rooms. Also when two spawn points overlap let them play paper scissor stone to survive( both create a random float the spawnpoint with the bigger number spawns the new room.
@pgr6713
@pgr6713 Жыл бұрын
thanks for the idea
@DustVoltrage
@DustVoltrage Жыл бұрын
Sometimes it looks to easy to be true, well, it is one of those case ^^ Don't get me wrong, I learn a bit with this series and I appreciate the effort and time to make it. Unfortunately as soon as you want to expand on it, the whole thing breaks appart. I managed to clean and expand a bit, but I just can't find a way to avoid the edge case where an open door meets a closed wall. You would need to check conditions 2 rooms ahead and this system where each SpawnPoint generates the next one just don't allow that. Too bad, I feel like I need to start all over again :/
@Coder420
@Coder420 2 ай бұрын
For anyone having 4 rooms and /or error: " Tag SpawnPoints not defined "check if in code you didn't wrote SpawnPoint because without that s or vice versa it will spawn just those 4 rooms around but it wont continue
@gradi02
@gradi02 Жыл бұрын
if you make "empty room" there will be one way doors... so better option (tested) is in this place Instantiate start / 4 door room and after this repeat "Invoke" function to make next rooms :D
@gradi02
@gradi02 Жыл бұрын
im also now trying to use this mechanics to make sure that there wont be any one way doors... just replace old room with 4door room
@emche852
@emche852 5 жыл бұрын
Awesome! First set of video that I watched on this channel - and already subscribed, cool and fast content keep up great work! :3
@WindRideres
@WindRideres 5 жыл бұрын
Hey! any plans on continuing this? i know you say this is the end, but it could be nice if you continue this with different size rooms and/or randomized interiors. amazing vid btw, you earned a subscriptor here n.n
@Yami1337Gaming
@Yami1337Gaming 6 жыл бұрын
Your tutorials have spared me so many headaches! Cheers!
@Blackthornprod
@Blackthornprod 6 жыл бұрын
I'm so glad to hear that :) ! Best of luck !
@febz4761
@febz4761 6 жыл бұрын
Great tuts, great channel! Can you make second video with various size rooms?
@Revampness
@Revampness Жыл бұрын
Thank you for this. I was trying to implement this is godot but could not find any good tutorials. I guess the saying is true, “ when you know one language, you know them all.
@abedabdesselem9491
@abedabdesselem9491 3 жыл бұрын
If u want to get an even bigger level just add the start room to all of the arrays, it ll give way bigger rooms since the start room have 4 openings
@Dreams_Of_Lavender
@Dreams_Of_Lavender 3 жыл бұрын
Yeah, I was thinking about that. Like, why no T-shaped rooms or using the 4-way junction room as a block in the dungeon too? I'd also allow a room with two openings and the T-shaped one to be used as a spawn room as well.
@dylanenriguehuntington2908
@dylanenriguehuntington2908 Жыл бұрын
Very simple system, also very flawed but i'm glad I could implement it quickly into my game jam game.
@mykodagames
@mykodagames 6 жыл бұрын
Questions: 1) How do you get your player in the room. 2) how would you show a minimap of the rooms at the same time? Appreciate any suggestions 😁
@oristarstorm6863
@oristarstorm6863 5 жыл бұрын
My assumtion was that this was going to be the minimap.
@hirnick6493
@hirnick6493 5 жыл бұрын
You can always add a top camera orthographically and use it as a mini map on the HUD.
@ikercanut1259
@ikercanut1259 6 жыл бұрын
I don't know what to say man, you rock
@PixellateYT
@PixellateYT 4 жыл бұрын
I have combined this video and random map generator video to create a game, It was very useful and it is the only video about random dungeon and random map generator.Btw I subbed
@lens3973
@lens3973 4 жыл бұрын
So I've got pretty far into making a game based on this tutorial, I'm a complete beginner, it's my second game ever, but I;m having so much fun! I was able to troubleshoot and fix everything except for the fact that the Boss can spawn in a filled room if it gets generated last
@jakublaszczyk1404
@jakublaszczyk1404 4 жыл бұрын
Check if AddRoom Script is on CloseRoom (That room that is filled in) and if it is there be sure to delete it. If this doesnt work then sorry but i cannot help you.
@lens3973
@lens3973 4 жыл бұрын
@@jakublaszczyk1404 thank you!! I actually just implemented a fix where if the last rooms name is the name of the filled room prefab then it spawns the boss an extra room back ✊
@thelongminecart7393
@thelongminecart7393 Жыл бұрын
the boss can spawn in the closed room
@JohnWeland
@JohnWeland 6 жыл бұрын
So close! RoomSpawner.cs:57 if (other.GetComponent().spawned == false && spawned == false) console gives me this error NullReferenceException: Object reference not set to an instance of an object RoomSpawner.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/RoomSpawner.cs:57)
@wingdeusrex7866
@wingdeusrex7866 5 жыл бұрын
I have the same problem how do I solve this?
@conanspit
@conanspit 4 жыл бұрын
I believe this is caused(atleast for some part.) by the fact that some of your colliders with the tag SpawnPoint, do not have the RoomSpawner script. Meaning that it tries to acces the spawned value of a non-existent script. too avoid this, try using Other.Gameobject.TryGetCompenent(). putting this in an if statement will allow you to only run your code if the other object actually has the component you are looking for.
4 жыл бұрын
@@conanspit Hi, Thanks, I have the same problem, I'm a beginner and i don't completely understand why I have this error, I tried using your solution but I have this error, could you pls hel me? error: Assets\RoomSpawner.cs(59,34): error CS1501: No overload for method 'TryGetComponent' takes 0 arguments
@conanspit
@conanspit 4 жыл бұрын
@ TryGetComponent() isnt the full code, its the function you can use. the full code would be this: if (other.gameObject.TryGetComponent(out RoomSpawner spawner)) { Instantiate(templates.closedRoom, transform.position, Quaternion.identity); } in TryGetComponent: out = a keyword, just needs to be there RoomSpawner = the script or component you are trying to Get spawner = the reference/variable the component you Get is stored in to use inside the if statement You got that error because you need to have those three 'arguements' in TryGetComponent, that is what it is trying to tell you
@lorenzorossi9718
@lorenzorossi9718 4 жыл бұрын
you just need to remove the SpawnPoint tag from the destroyer
@AWPFanYuu
@AWPFanYuu 5 жыл бұрын
I don´t know why but after I added the Destroyer script I´m having a nullreferenceExeption for the line if (other.GetComponent().spawned == false && spawned == false)
@ramadandu75
@ramadandu75 5 жыл бұрын
Me too :/
@kn0wmad1c
@kn0wmad1c 5 жыл бұрын
I got that too. It's because the RoomSpawner is removed. Change it to this, it's what worked for me: try { if (!collision.GetComponent().spawned && !spawned) { Instantiate(templates.closedRoom, transform.position, Quaternion.identity); Destroy(gameObject); } } catch (System.Exception e) { Destroy(gameObject); }
@milkmanken5354
@milkmanken5354 5 жыл бұрын
@@kn0wmad1c Worked like a charm
@koralix0233
@koralix0233 5 жыл бұрын
@@kn0wmad1c Good solution!
@ArOwcraft
@ArOwcraft 4 жыл бұрын
@@kn0wmad1c You rock man, thanks
@_Garm_
@_Garm_ 6 жыл бұрын
Great tutorial series! keep up the great work
@nocultist7050
@nocultist7050 4 жыл бұрын
It breaks if rooms have more than 2 ways in/out.... I need that really... Please help.
@speckoh
@speckoh 6 жыл бұрын
this series is amazing! It's the simplest random dungeon generator tutorial available and works as an amazing framework! 4 Thumbs UP!
@Fragler01
@Fragler01 4 жыл бұрын
Very nice content :D I love the way you simplify teaching :D However, unfortunately it spawns rooms whith doors that leads into walls. If they were real door, like in the game Binding of Isaac, it would be awkward to have a door which opens to a wall :/ Also, what if I would like to tell the dungeon generator to have a certain amount of rooms? I would also like to know if this works with rooms with 3 openings.
@T1M3L3SS_
@T1M3L3SS_ 4 жыл бұрын
you could add 2 public ints on the RoomTemplates script(one called RoomCap and one called Rooms), then add the following lines to the RoomSpawner script: if (spawned == false && templates.roomCap >= templates.rooms) ** templates.rooms++; } then you should be able to limit how many rooms can spawn hope i could help :)
@Fragler01
@Fragler01 4 жыл бұрын
T1M3L3SS thank you for the idea. I have already made my own kind of room generator. I use vidual scripting instead of coding. I might do a video about it if you are curious. It can make as many rooms as you wish, with boss room and random interiors ☺️
@T1M3L3SS_
@T1M3L3SS_ 4 жыл бұрын
@@Fragler01 that would be interesting
@oneway7122
@oneway7122 4 жыл бұрын
I still have some rooms overlapping which is very annoying because it often happens at the boss room
@firebombgames3398
@firebombgames3398 4 жыл бұрын
This video series gave me a lot of ideas for my dungeon generator im about to start creating cudos on the great videos!
@sharathsunny4557
@sharathsunny4557 5 жыл бұрын
i am having closed room spawned in the middle of empty room could you help me with this
@robloxcoreenjoyer8848
@robloxcoreenjoyer8848 4 жыл бұрын
It happens because collider on destroyer is trigerred
@jackmcfetridge
@jackmcfetridge Жыл бұрын
Hmm, not sure how much this helps but I’m using this in 3D and I’ve found that Invoke(“Spawn”, .1f) is a little fast, especially considering I’m spawning 3-way and 4-way rooms It’ll spawn everything but sometimes there might be a 3 or 4 way overlap between spawn points and the engine doesn’t seem to be able to handle those at .1f speed super well, like 1 per tick but any more and it has trouble, I’ve found .2 works quite well though
@KevinFranca1
@KevinFranca1 6 жыл бұрын
great tutorial man, it helped me a lot, but I would like to know how do I keep rooms from having doors that leads to other room's walls?
@wtvdonot1135
@wtvdonot1135 5 жыл бұрын
Same Question Here, this is the only issue I have right now.
@DayMoniakkEdits
@DayMoniakkEdits 3 жыл бұрын
@@wtvdonot1135 Late answer but I found a trick to fix this issue. I put a empty gameobject with rigibdody and box collider set to trigger and place where I have doors. If nothing collide with this object : the door isn't leading to a wall. But if the wall of another room is detected I remove that wall and spawn a wall with a door at the same position
@BramLastname
@BramLastname 3 жыл бұрын
the Easy solution is to mirror the wall over top the doorway, The proper solution would be to have the part where doorways can lead to separate from the regular wall and make it able to be walked through if there's a doorway touching it
@horex_MTGA
@horex_MTGA 4 жыл бұрын
I want to know how to save the generated map. For example, it is a case of returning from 2F to 1F depending on the situation, rather than simply proceeding from 1F to 2F, 3F.. I would like to know how to save the information for 1F coming back. For example, whether a monster is alive or dead, a corpse, an item not acquired, a broken object, etc. I'm still inexperienced with Unity, so I don't know how other than a simple way to use get and set by simply specifying a few variables.
@ethanpillay9063
@ethanpillay9063 5 жыл бұрын
I'm not gonna make this but there were many lines of code I found useful thanks
@BlueberryTheShothair
@BlueberryTheShothair 2 жыл бұрын
Great ideas and helped me with my rouge-like project! But I have a small question, that in the update method of room templates script, why not just Instantiate the boss in room[rooms.Count-1], is the for loop and if statement necessary?
@berkefekeskin9172
@berkefekeskin9172 3 жыл бұрын
Thank you for these tutorials
@Dreamlander
@Dreamlander 6 жыл бұрын
hey - awesome channel! - plz keep doing vids.. I hate that every good channel I find that does new stuff in Unity still has quit making vids. Hoping to start doing vids like this on my channel soon and I have about the same amount of subs - maybe we could even do a collab sometime! :) Thanks for the great content - Brad
@Blackthornprod
@Blackthornprod 6 жыл бұрын
Thanks :) ! Don't worry, Blackthornprod's journey has just begun !
@Dreamlander
@Dreamlander 6 жыл бұрын
Good to hear! will follow and recommend then.
@ccr0co974
@ccr0co974 2 жыл бұрын
why do i keep getting error at the closed wall Object reference not set to an instance of an object
@chickenmission9156
@chickenmission9156 3 жыл бұрын
hey man, i know a few people have asked this, and even though this is super old and you probs wont even reads it, different sized rooms would be awesome, and if you could make a video on it that would be awesome
@finleychapman9315
@finleychapman9315 3 жыл бұрын
I'm currently having a problem where it spawns in a lot of rooms, does anyone have any idea of how to limit the amount of rooms that get spawned in
@knack3381
@knack3381 3 жыл бұрын
if you decided to add rooms with three or four exits (the tutorial only has rooms with 1 exit and rooms with 2 exits), try increasing the chance for a single or double exit room in the Room Templates array (in the gameobject. i dont think you need to mess with the script).
@mittensandsnowdrop
@mittensandsnowdrop 2 жыл бұрын
I added a public static int roomCount to my RoomSpawner script. Then incremented it by 1 everytime I spawned a new room. Then I made a public int maxRooms on the roomTemplates script, (so I could edit it in the editor) and made an if (roomCount
@CaffeinedOwl
@CaffeinedOwl 6 жыл бұрын
Can you make a tutorial about the interiors ?
@OHUMADBRO1
@OHUMADBRO1 6 жыл бұрын
My destroyer doesn't seem to function. I added a debug.log and it is indeed colliding. But the closed room still spawns. I'm at a complete loss. Help please (:
@hirnick6493
@hirnick6493 5 жыл бұрын
For a trigger collider to work properly. It requires a rigid body on either both of the objects or simply the one that is the trigger.
@itspietime314
@itspietime314 4 жыл бұрын
Make sure your Destroyer gameObject doesn't have the "SpawnPoint" tag
@CostGazelle
@CostGazelle 4 жыл бұрын
try to add box collider 2d to clossed room with is trigger
@jasmijn-1419
@jasmijn-1419 4 жыл бұрын
Thank you so much, i got stuck there😅
@daspoboy2781
@daspoboy2781 3 жыл бұрын
What should I do to adjust the minimum and maximum amount of rooms a level should have? I don't want the first level to have too many rooms, but I also don't want a scenario where the first level is shaped like a plus sign.
@JoeAC5000
@JoeAC5000 4 жыл бұрын
I keep getting openings to the scene space. The fix at 1:00 only seems to work when two rooms collide, it does nothing when the opening isn't next to another room.
@conanspit
@conanspit 4 жыл бұрын
Check to make sure that all room openings have a spawner, i think this can only happen when that is the case.
@slendercat3824
@slendercat3824 6 жыл бұрын
Thanks! You helped me a lot)
@КотюкГеоргий
@КотюкГеоргий 4 жыл бұрын
Please, make tutorial how to make rooms in different sizes))). Pleeeeease
@Phamility
@Phamility 4 жыл бұрын
I think just replace his images with your own and adjust the room spawners
@flancanstain
@flancanstain 4 жыл бұрын
@@Phamility if you could help us even if you did a little mini tutorial would be amazing :)
@KageTrips
@KageTrips 4 жыл бұрын
I've tried to make 2x1 rooms as a test and I think it confuses the system because I've never once got it's second door to be able to connect to the door of another room. more often then not it triggers the Closed wall code on the second door just leading to a closed off room.
@Ngbaka1
@Ngbaka1 6 жыл бұрын
Great video! Is there a way to make rooms stop spawning with open doors that lead to a wall of another room? Example at 4:50 with the left top room. Thanks!
@RTWrename
@RTWrename 4 жыл бұрын
trying to resolve that problem to
@conanspit
@conanspit 4 жыл бұрын
A sort of fix for this could be to add some more Colliders with for example the tag 'WallChecker' with a seperate script where the opening of the other room should be. if these WallCheckers collide with a wall, you can have them either destroy the walls they are in contact with, opening the way, OR have them a wall so that the way is closed on both sides.
@Flusap
@Flusap 6 жыл бұрын
thanks man this helped me a ton
@viniguerrero
@viniguerrero 5 жыл бұрын
How can we avoid dead ends? Like a map with a single random path, one start room and one end room?
@pixeldustinteractive
@pixeldustinteractive 5 жыл бұрын
The wall room doesn't work for me, it spawns at random times whenever there are more than one room in a group. Not sure if I did something wrong but seems kind of a bad design imo... trying to find a workaround for it...
@quak7407
@quak7407 4 жыл бұрын
If anyone gets a null reference exception when instantiating a closed room, you need to add this to the OnTriggerEnter2D function: templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent(); As far as I'm aware, the OnTriggerEnter function is being run before the Start function, meaning that templates is being returned as null and causing an error. Hope this helps someone!
@PauSanchez63
@PauSanchez63 4 жыл бұрын
I've been trying quite everything unless this before seeing your comment, thanks so much!!
@gamingtotdemaxi
@gamingtotdemaxi 4 жыл бұрын
didnt work
@ptaroworm7887
@ptaroworm7887 3 жыл бұрын
Thanks!
@NotifrikiTV
@NotifrikiTV 2 жыл бұрын
Thaniks !!!!!!
@r1pfake521
@r1pfake521 6 жыл бұрын
Do you write your code this way because you want to keep it "easy"? Because the code is, well i don't want to sound rude, but it's not very "nice". For example the for loop to get the last element of the list, you can just use the indexer of the list and get the last element instead of using a loop. Also in your spawn method there is a lot of copy&paste code where you only changed the list, if you start to copy&paste code you should always thing about creating a method if possible to avoid duplicated code for example in this case you could make a method and just pass the list. These are only "small" things but if you care about these things your code will be cleaner overall.
@pancake-th7qy
@pancake-th7qy 6 жыл бұрын
Are you one of those fuckers thats all OCD about their code?
@boltstrikes429
@boltstrikes429 5 жыл бұрын
Mhm, it kind of threw me off when he used a for loop to find the last object in his list. But then again, this entire method is inefficient, so its not like it matters
@NationalGamingNL
@NationalGamingNL 5 жыл бұрын
333pancake333 Its not OCD... These little things can actually take up alot of memory in the end so doing these things in a more efficient way isnt a bad idea at all.
@Luk3r
@Luk3r 5 жыл бұрын
You mean good programmers? If you don't want to be "OCD" (i.e. efficient and concise) then coding isn't for you.
@calmsh0t
@calmsh0t 5 жыл бұрын
@@pancake-th7qy If you want to be a somewhat decent programmer you better start being very critical about your code and think 10 times about what you did and if there isn't a faster, smarter, shorter and easier solution.... completely unnecessary comment to a valid point. And he is indeed very right!! Writing ONE method and simply passing in the value to access the array would've been a way smoother approach. Stuff like that might not matter in a small 2D Game on a standart pc in the year 2018, but once you are going for bigger projects such stuff will add up and matter a lot. Plus, it adds to the readability of your code.
@zZLibikiZz
@zZLibikiZz 3 жыл бұрын
I appreciated the effort and love the video but the script is pretty bad, there are bugs that you didn't cover as well
@_highlevel_
@_highlevel_ 2 жыл бұрын
The destroyer destroys my player
@luck8762
@luck8762 2 жыл бұрын
you can use a layer for your player and make it not interactive with the destroyer layer in Edit-> project settings -> physics
@sigorharaldsson4067
@sigorharaldsson4067 6 жыл бұрын
I'm doing this in 3d. It works well, except it spawns closed rooms into every room
@wafflehidraulico193
@wafflehidraulico193 4 жыл бұрын
I got a problem, I couldn't even generate the dungeon, all I got was a bunch of errors saying "NullReferenceException: Object reference not set to an instance of an object RoomSpawner.Spawn () (At Assets/Scripts/RoomSpawner.cs:47)" "NullReferenceException: Object reference not set to an instance of an object AddRoom.Start () (At Assets/Scripts/AddRoom.cs:13)" "NullReferenceException: Object reference not set to an instance of an object RoomSpawner.OnTriggerEnter(UnityEngine.Collider.other) (At Assets/Scripts/RoomSpawner.cs:58)" "NullReferenceException: Object reference not set to an instance of an object RoomSpawner.Spawn () (At Assets/Scripts/RoomSpawner.cs:41)" "NullReferenceException: Object reference not set to an instance of an object RoomSpawner.Spawn () (At Assets/Scripts/RoomSpawner.cs:38)" The code is exactly the same as from the video, the only difference are the colliders2d, in my project they are 3d because my project is in 3d
@Snake_Snatcher
@Snake_Snatcher 4 жыл бұрын
I just had this error and mine was fixed by removing the "Rooms" tag from my prefabbed rooms. The only thing that should have that tag is your Room Templates object I believe.
@SpringBreakBr
@SpringBreakBr 6 жыл бұрын
Can i make it stop to generate rooms with open to walls of others rooms ?
@conanspit
@conanspit 4 жыл бұрын
A sort of fix for this could be to add some more Colliders with for example the tag 'WallChecker' with a seperate script where the opening of the other room should be. if these WallCheckers collide with a wall, you can have them either destroy the walls they are in contact with, opening the way, OR have them a wall so that the way is closed on both sides.
@ArOwcraft
@ArOwcraft 4 жыл бұрын
To the people struggling with the "open door to closed room" problem ( 4:50 top left room ) i may found one "solution" First: You need to add 2dRigidbodys(is kinematic active) and 2dBoxColliders to all your walls. In every room create a empty GameObject with a 2dBoxCollider and set it to isTrigger, and place it where the "doors" to the others room should be. Close the room door openings with walls, set these walls to disabled on inspector. Create a C# script and drag it on the gameobject with the collider previously created. public GameObject[] Door; //to receive the doors you disabled on the inspector private void OnTriggerEnter2D(Collider2D collision) { //if the collider we created hit another room this will trigger for (int i = 0; i < Door.Length; i++) { Door[i].gameObject.SetActive(true); //the doors we setted to disable will be enabled } } don´t forget to drag the disabled doors on the gameobject script, and repeat the process with every room with openings, srry my bad english, not native, hope to help anyone.
@oj-te1uw
@oj-te1uw 2 жыл бұрын
thanks for tha help
@lizkimber
@lizkimber 4 жыл бұрын
For some reason converting this to 3d hasnt worked as well as I hoped. The "Room there" detection seems to fail. despite using all the right colliders, rigidbody etc. In the end I did nothing like this, I used a dictionary with a vector2 location, from the start room, and a simple data component with what exits are available.. runs like a dream, even goes and corrects when 2 rooms end up disagreeing what a middle room should have.. and all is fine
@crossfire9923211
@crossfire9923211 4 жыл бұрын
Hey! I also tried to 3D and it didn't work very well. Can you explain how you made it work? Thank you Liz.
@okamichamploo
@okamichamploo 5 жыл бұрын
What is preventing rooms with doors leading into another room's wall from spawning? Did I miss part of the script?
@loes4292
@loes4292 5 жыл бұрын
I am struggling with this too. Did you fix it yet?
@GameSmith
@GameSmith 4 жыл бұрын
@@loes4292 Anyone figure this out? also I'm not a fan of the big closed room blocking off the path.
@thealternian3476
@thealternian3476 2 жыл бұрын
I'm encountering a problem with my code. I'm following the tutorial, although translating it for my 3D project. The room that is supposed to spawn when two or more spawners intersect doesn't, and my maze is full of holes because of it. I am getting a NullReferenceException on the line where it instantiates the full room. I made sure the object was placed in the code, but it doesn't want to acknowledge it for some reason. Has anyone had a similar problem and if you have fixed it, what did you do?
@Happyhenzo
@Happyhenzo 2 жыл бұрын
Having the exact same problem and no idea why. I've done everything exactly like he did
@6Abdellah9
@6Abdellah9 Жыл бұрын
saaame have u figued it out
@thealternian3476
@thealternian3476 Жыл бұрын
@@6Abdellah9 No, I couldn't due to my computer melting for unrelated reasons. I think it was misidentifying the node and was either deleting it or I completely left out an if node interacts with other node section. I have yet to look into this since as I have been busy with other things. I hope you'll figure it out. It could also be a 3D thing.
@lyrick3603
@lyrick3603 3 жыл бұрын
In case anyone faces the error that some rooms are generating on top of each other and that the ClosedRoom is not working, I had this same problem and needed to create a public GameObject in the Room Spawner file, after that I had to put the closedRoom in it and instantiate it this way to solve this bug.
@victoryllama1
@victoryllama1 Жыл бұрын
But this tutorial means that doors can open into walls, which is not an ideal look, is there a way to fix this
@wolker213
@wolker213 3 жыл бұрын
But still there is the bug, like in 4:51, where there is enterance but wall on other side...
@cortlandia7618
@cortlandia7618 3 жыл бұрын
This also works in 3d if you change some of the code
@denisaflitunov1559
@denisaflitunov1559 6 жыл бұрын
Very cool video! Keep up the good work! I would like to see more videos about procedural generation с:
@quaintgamestudio6149
@quaintgamestudio6149 3 жыл бұрын
Thank you so much
@MikeKing710
@MikeKing710 6 жыл бұрын
I don't know which game to use this method, but it's funny to see how it's work)
@Blackthornprod
@Blackthornprod 6 жыл бұрын
Hey :) ! It's great to have already followed the hole series, in the future it may come in handy !
@MikeKing710
@MikeKing710 6 жыл бұрын
Yeah.. I didn't see previous videos about this tutorial series;/ maybe I'll take a look later. I never play game "The Binding of Isaac" because don't know what gameplay there are
@Blackthornprod
@Blackthornprod 6 жыл бұрын
The binding of isaac gameplay is very simple, move and shoot a bunch of monsters in a randomly generated dungeon. You also pick up items, pills and cards that effect your stats and visual look. All in all a great game, definitely worth a buy :) !
@MikeKing710
@MikeKing710 6 жыл бұрын
What do you make next tutorial?)
@RONdomTheology
@RONdomTheology 4 жыл бұрын
This was very helpful Thank you! I look forward to your videos! I have a questions though about the code. It worked the first time I tried it when I used the basic white rooms, but when I made my rooms different it stopped working and some rooms destroyed themselves, I made them longer but changed the spawn point accordingly. Could you have any advice? Thank you, I'll keep trying!
@rogerbusquetsduran5596
@rogerbusquetsduran5596 6 жыл бұрын
I'm following the same process, but in 3D, most of the times it work well, but sometimes some rooms block the entrance of others and I end up with closed rooms. Any idea how can I solve this? Apparently one of the instances is not being destroyed but the spawn points are destroyed. I mean that the room that is provoking the issue is always a room that appear there with no spawn points at all. (I've ckecked all the prefab twice and the directions are okay and they are also included in the proper arrays).
@Nythlin
@Nythlin 6 жыл бұрын
Ditto man
@stan4079
@stan4079 Жыл бұрын
you found a solutions man??
@connorlawless235
@connorlawless235 2 жыл бұрын
Followed everything perfectly, and still getting rooms spawn on top of each other, and rooms with doors that lead to walls. Anyone have a quick fix?
@NormalHuman5
@NormalHuman5 Жыл бұрын
Did you find a fix?
@jim-wood
@jim-wood 6 жыл бұрын
What changes would you make if you wanted to ensure that all rooms that were connected to one another have a door connecting the two? For example, in Isaac, any room that is next to another room HAS to have a door to that room. Cheers!
@lanpak1126
@lanpak1126 5 жыл бұрын
ever heard of a shop/trinket room?
@Alex-mm2vw
@Alex-mm2vw 4 жыл бұрын
The fix at 2:30 doesn't fix it for me, the closed room is spawning right into my Entry room. Does anyone here have a solution ? The only thing the Destroyer does it destroying my Player Character and a platform, but I think I would be able to fix that.
@Alex-mm2vw
@Alex-mm2vw 4 жыл бұрын
I just noticed, that everytime I press play on my game now, the whole program becomes irresponsive and I need to open my task manager.
@JoeAC5000
@JoeAC5000 4 жыл бұрын
Are all of your spawn point's Rigidbody's set to kinematic? I had the same problem because some of mine were set to Dynamic.
@emilysimo4841
@emilysimo4841 3 жыл бұрын
Is anybody else having rooms direct into eachother. The rooms aren't spawning on top of eachother but some have doorways that run into the wall of an adjacent room and don't lead anywhere?
@emilysimo4841
@emilysimo4841 3 жыл бұрын
I figured out my issue. Some of my prefabs had a rigidBody2D attached to the gameObject containing the room's sprite. This caused the wall rooms to be deleted instantly.
@HockeyPlayer323
@HockeyPlayer323 5 жыл бұрын
Hey! I've been working with your tutorial for a few days and have some questions. If you have the time to chat, that'd be awesome! Thanks for the great content!
@r_pasta2228
@r_pasta2228 6 жыл бұрын
Why did you use a for loop to loop through the values and then instantiate boss in the end? You could just instantiate the boss in the room of the last index directly by using (list.Count - 1)
@HomikiGaming
@HomikiGaming Жыл бұрын
Someone know how to make it without repeat of each room? Pleas help
@Phamility
@Phamility 4 жыл бұрын
2 tips for you - This can't implement 3 door rooms Long rooms can be made by changing the pivot point and having 3 spawn points on their sprites
@flancanstain
@flancanstain 4 жыл бұрын
im really trying to have longer rooms so tat it fits the game scene screen without seeing the other rooms could you help me with that please?
@signalised9540
@signalised9540 4 жыл бұрын
can you elaborate what you mean by having 3 spawn points on their sprite and changing pivot?
@jamesbryanttin1574
@jamesbryanttin1574 6 жыл бұрын
why am I having infinite rooms :( help me bro. Good video btw
@TehSemiN4p
@TehSemiN4p 5 жыл бұрын
For me the Problem was that my spawnpoints had the wrong order..
@Minkstars2023
@Minkstars2023 5 жыл бұрын
I may be late but make sure you've set all the box colliders to trigger
@TiltmasterYatorik
@TiltmasterYatorik 5 жыл бұрын
@@zedespook Also late, but this was the problem for me too. My stupidity got the worst of me when calling the left/right/etc. rooms. Thanks
@gaminggaming7658
@gaminggaming7658 5 жыл бұрын
If you have rooms with more than 2 openings, they can multiply exponentially, be careful with 3 or 4 door rooms.
@qwertz3813
@qwertz3813 10 ай бұрын
Has anyone solved the fact that the doors do not fit exactly on each other and there is some offset?
@therealsanicspeed2909
@therealsanicspeed2909 4 жыл бұрын
how to set a limit of spawning rooms
@fullpixels513
@fullpixels513 4 жыл бұрын
Don't forger adding boxCollider2D with trigger to your closeRoom ...
@rogeraguilaremanuel8056
@rogeraguilaremanuel8056 3 жыл бұрын
would it be better in terms of performance to add a public RoomTemplates variable and assign it by script instead of making a find? as far as I know finds are expensive
I rewrote my dungeon generator!
4:27
UnitOfTime
Рет қаралды 160 М.
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 67 МЛН
How Strong is Tin Foil? 💪
00:26
Preston
Рет қаралды 150 МЛН
How to Code (almost) Any Feature
9:48
DaFluffyPotato
Рет қаралды 685 М.
5 DEVS Make a GAME without COMMUNICATING! (FPS edition)
19:10
Blackthornprod
Рет қаралды 474 М.
Procedurally Generated 3D Dungeons
9:42
Vazgriz
Рет қаралды 289 М.
Procedural Generation in Unity (Tutorial)
10:29
Nebula Coding
Рет қаралды 76 М.
Unity's New Input System:  The Definitive Guide
32:07
DmanGames
Рет қаралды 29 М.
Dungeon Generation in Gun Game
8:18
Firebelley Games
Рет қаралды 67 М.
I Made A Difficult Game About Climbing
15:04
Pontypants
Рет қаралды 2,1 МЛН
4 DEVS Make a GAME without COMMUNICATING! (Motion Capture edition)
17:27
6 Years of Learning Game Development
17:20
Cobra Code
Рет қаралды 147 М.
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17