RANDOM DUNGEON GENERATION - EASY UNITY TUTORIAL - #2

  Рет қаралды 155,423

Blackthornprod

Blackthornprod

Күн бұрын

Пікірлер: 377
@Blackthornprod
@Blackthornprod 6 жыл бұрын
Hey :) ! Right at the END of the video I add to my IF STATEMENT : && other.GetComponent().spawned == true Do NOT add this to your if statement, it will get the entry room packed with extra rooms !
@Blackthornprod
@Blackthornprod 6 жыл бұрын
Make sure each room spawns with a slight time delay (so they don't all spawn at the same time and you have a chance to fix the issue without Unity crashing ) and make sure you have one door rooms, which don't spawn any other rooms because the one opening they have already leads into another room, as a result the room spawn point doesn't instantiate anything ! Hope this helps :) !
@lhenardabraham9068
@lhenardabraham9068 6 жыл бұрын
It spawns unlimited rooms :O
@Sebastian-vx6jc
@Sebastian-vx6jc 5 жыл бұрын
I guess i found the solution. It generated unlimitied rooms aswell and i simply invoked all opening directions. I guess alot of you guys made the same mistake as me. When youve got a room with a door at the top u need to direct it to a room with a spawnpoint in the bottom. Example: Bottom = 1, Top = 2, Left = 3, Right = 4. When youve got a Room with a Door (and Spawnpoint) at the top, the value of the Opening Direction is 1, because you want it to link with a Room from the Bottom Array. Hope i could help
@Braderzian
@Braderzian 5 жыл бұрын
When I delete that part of the code nothing spawns from the starting room, but without deleting this I still have issues with rooms not spawning correctly, as if the rooms are ignoring code, I have a picture if that will help you understand me, thanks.
@mello-rl6418
@mello-rl6418 5 жыл бұрын
@@cornflakestoasted I just faced this issue bro, make sure there's no Spawnpoint on the Closed room
@memoal-said5111
@memoal-said5111 2 жыл бұрын
For those who still had trouble with rooms generating infinitely and rooms would generate on top of each other, the solution I came up with was to add another spawnpoint on the center of the rooms you want to generate BUT make sure the room spawner script isn't on them and the new spawnpoints on the center still has that spawnpoint tag. The spawnpoint tag is needed to erase any new room's spawnpoints colliding with it so it doesn't secretly generate new rooms. I noticed the rooms keep generating on top of each other and infinitely because there was no accurate way to tell the room spawners if there's a room ontop of them. This also removes most of room spawners that would normally be present after room generation has completed. I tested this in 3D and got it working with this tutorial along with my solution above. It should work with 2D as well but I haven't tested from my side, theoretically it should work with 2D. Hope this helps.
@christinaVennegerts
@christinaVennegerts 2 жыл бұрын
Oh, finally! This one worked for me, thank you so much =)!
@quoctrungtran6403
@quoctrungtran6403 Жыл бұрын
U Saved me
@Emilis2023
@Emilis2023 Жыл бұрын
Yeah, still getting a few unwanted quarks, but I imagine that may be what he'll clean up in Part 3. This made it work a lot better though! (In 2D btw, so yes, your fix seems to be effective there as well)
@valeryisfreedom
@valeryisfreedom 10 ай бұрын
🤩
@eribetra
@eribetra 2 жыл бұрын
For anyone whose project is only spawning four rooms, check that you have set the Opening Direction int on every prefab's Spawn Point, not just on the Entry Room, and also try making all of the Spawn Points' 2D Box Colliders smaller.
@tatepayton7368
@tatepayton7368 2 жыл бұрын
That fixed it!
@change9907
@change9907 2 жыл бұрын
God bless you. Thank you. I was just about to close unity.
@ncpokemonfan
@ncpokemonfan 4 жыл бұрын
For anyone who is trying to do this with tilemaps, but only the entry room shows in the game viewer, this is what I did to make it work: Instead of declaring templates.roomarray[rand] inside of the Instantiate method, create a temp variable right outside of the method and then use that variable to instantiate it. Ex: var room = templates.nRooms[rand]; Instantiate(room, new Vector2(transform.position.x, transform.position.y), Quaternion.identity); I am not sure why this works, but I assume Unity has a somewhat skittish attitude towards generating tilemaps via code and will instantiate them but not render them in the game preview if it is called directly from the instantiate method. Hope this helps!
@sinningchickenco.2481
@sinningchickenco.2481 3 жыл бұрын
im new to development. im having the exact issue your describing but i have no clue how to fix it cause i have no clue what you just said...you got a visual representation?
@Phamility
@Phamility 4 жыл бұрын
If infinite stages are spawning check the following - Re-look that you set the correct opening direction for each room 1 top 3 right 2 bot 4 left Re-look whether you put this order in the coding part 1 = bottom 2 = top 3= left 4= right
@kbenskeer5071
@kbenskeer5071 4 жыл бұрын
doesnt work for me :(
@criticalhitentertainment
@criticalhitentertainment 4 жыл бұрын
Thanks! That helped me a lot!
@dorieta_gaming
@dorieta_gaming 2 жыл бұрын
For the 22's people here, You need to declare the "rand" is a variable in order for it to work (Unity 2021 LTS) you can just do var rand = Random.Range(0, templates.bottomRooms.Length);
@Emilis2023
@Emilis2023 Жыл бұрын
I may be 5 years late to the party, but I love this! I've been playing with game design for less than a week now so I'm extremely new to everything, but this was something I was really looking for and it's working great now! Your explanation was very detailed and beginner friendly and besides just having a working random room generator in my project I feel like I really understand the structure of the script a lot better thanks to your clear explanations of the purpose of each method and such. Thanks a ton!
@martinl1523
@martinl1523 Жыл бұрын
welcome
@husk160
@husk160 5 жыл бұрын
Love your videos! I recently got into unity and had a really cool idea for a dungeon crawler of sorts, but I wanted it to be randomly generated, and thankfully your video was here to help me! Thanks ♥️
@micaiahstevens8840
@micaiahstevens8840 6 жыл бұрын
Wrote most of the entire project from Video one, and made it completely programmatically. But love your 4 lists of objects, I just made one huge list.
@micaiahstevens8840
@micaiahstevens8840 6 жыл бұрын
Of course I wrote all the meta data by hand, but I could scan the picture and find the doors.
@felipezymor9970
@felipezymor9970 2 жыл бұрын
Can you share with us the code?
@NPOCrushader
@NPOCrushader 5 жыл бұрын
Not sure why. But my rooms keep spawning infinite.
@oliverscott6913
@oliverscott6913 4 жыл бұрын
Yeah this is because you need to add a spawn point to the centre of your starting room and set its opening direction to 0 so therefore your start room cannot be spawned on top of and also the centre spawn point does not spawn any rooms
@st41n3d2
@st41n3d2 4 жыл бұрын
@@oliverscott6913 Thank you for this
@Cvile69
@Cvile69 4 жыл бұрын
@@oliverscott6913 OOOOOOOOOOOOOOOOOOOOOH GOD DAMN IT thanks
@Cprime38
@Cprime38 3 жыл бұрын
For future people, don't forget to tag Spawn points too.
@lyrick3603
@lyrick3603 3 жыл бұрын
@@oliverscott6913 I love you, you just saved me.
@NotifrikiTV
@NotifrikiTV 2 жыл бұрын
IF YOU ARE DOING IT ON 3D : Make sure that the position of the plane of your room floor is 0,0,0 . Not the empty , the plane. That fixit for me.
@horex_MTGA
@horex_MTGA 4 жыл бұрын
This is a very attractive video. I had 3 problems. 1. Only 4 rooms were created in the Entry Room. 2. The entry room and the door of the created room are not connected. 3. Infinite room creation problem as a result is created even if doors are not connected between rooms. It seems to have been resolved as a result of editing through videos and comments. 0. If the script is created indefinitely due to a mistake, there is a possibility that Unity itself will stop, so enter 0.1f of Invoke as a larger value. I entered 5 After that, if it works normally, it is recommended to change the value again. 1. The value of the Opening Direction of Spawn Point in the prefabs and entry room must be entered opposite to the direction value comment of the if statement written in the script. Spawn Point is 1 for the top, 2 for the bottom, 3 for the right, and 4 for the left. 2. Create one more Spawn Point as 0,0 in all rooms and enter the value as 0. 3. Change the Transform position of the prefabs to 0,0 (not sure) I'm sorry if I can't do this. Since I am unskilled, I cannot help you anymore.
@zombievirals
@zombievirals 6 жыл бұрын
Thank you so much!! When I first started learning game development a few months back, I was intimidated by the thought of this kind of random generation, but after this tutorial I've gained a pretty good understanding. I even built my own rooms that were more of a rectangle shape, which made it difficult at first because I had spawn points wrong in many places and had to go back and fix them manually. But once I got it straightened out, good as gold!! :)
@YasserSedrati
@YasserSedrati 6 жыл бұрын
at some point moment i was thinking i am watching "Brackeys" haha, *your videos in progress!*
@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
@itsspider6156
@itsspider6156 4 жыл бұрын
I don't understand, what 2d colliders?? the box collider?
@javedakhtar1435
@javedakhtar1435 6 жыл бұрын
most clean random dungeon spawner 😮 btw, i think there should be templates.bottomrooms.length -1 or at the instantiate(templates.bottomrooms[rand-1] since an array havin 0,1,2 will return 3 but the max index will be 2 also wont it be performant if the roomspawners are destroyed after instantiating the rooms since they have rigid bodies I CANT WAIT TO SEE THE THIRD ONE!!! I WAS WAITING FOR THIS SINCE THE FIRST VID'S UPLOAD pls upload 3rd one soon 😀
@Blackthornprod
@Blackthornprod 6 жыл бұрын
True enough :) ! For optimization reasons it would be clean removing all spawn points once the dungeon is generated ! And of course episode 3 will come out soon (2-3 days), so stay tuned :) !
@javedakhtar1435
@javedakhtar1435 6 жыл бұрын
Blackthornprod trying to wait 😁
@bunggo9914
@bunggo9914 6 жыл бұрын
super cool! this is really helpful... and I realize that you change your music style... which is awesome! can't wait for your next video :D
@sohaybalnajjar4968
@sohaybalnajjar4968 4 жыл бұрын
Help..and thank you Edit for just organizing my comment : 1st: The position of the spawning room not the same of spawn points (not above on each other in vertical manner or horizontal one). 2nd: to see the spawning rooms I need to zoom out .
@thegoodbuddy1550
@thegoodbuddy1550 3 жыл бұрын
hey mate i know its been 10 months but have you found a solution for the first problem
@sohaybalnajjar4968
@sohaybalnajjar4968 3 жыл бұрын
@@thegoodbuddy1550 i can't remember to be honest i left programming for some college purposes but. As long as i can remember there was a problem in Z axis that cause the problem. maybe z axis of the prefabs
@sohaybalnajjar4968
@sohaybalnajjar4968 3 жыл бұрын
@@thegoodbuddy1550 i can remember there was a solution on the internet either unity Q&A or youtube
@thegoodbuddy1550
@thegoodbuddy1550 3 жыл бұрын
@@sohaybalnajjar4968 ohh yea i think i found the problem thanks for your help
@sinningchickenco.2481
@sinningchickenco.2481 3 жыл бұрын
so it spawned infinetly. and while reading through the ciments i notice alot of you saying its that i got the number wrong hes placing a room above another room would need a 1(bottom) room but the infanite problem i have is its just creating an infanite grid of cubes that crashes unity
@orrianicon1428
@orrianicon1428 5 жыл бұрын
Now noticing rooms spawning on top of my entry room. Cutting off doorways out.
@MidoriLetsPlay
@MidoriLetsPlay 4 жыл бұрын
Have you found a fix?
@krispyabroad
@krispyabroad 4 жыл бұрын
@@MidoriLetsPlay In part 3 he makes a destroyer script, which is on a new spawn point that's in the middle of the entry room. Make sure that it's untagged too. It takes care of keeping the entrance clear
@hellxsan
@hellxsan 4 жыл бұрын
Hint for all of you, if your rooms don't spawn properly, spawning in middle of your "First room" or far away, The problem here is the Pivot, I noticed it as i does this tutorial on my 3Dprojeckt. The Pivot was in the left top corner of all my Rooms so they spawned wrong. I just Reposition the Spawners in every room so they spawn properly. The Second way is to Do a "fake Pivot" its mean you need to do a Parent object above, so the "room" is a child of the object then you need to Put the Parent(Fake Pivot) in the middle of every room, You need to change it on the prefab ofcourse then you need to put the " new rooms" in the RoomsTemplates script(And object) otheryway they would not spawn as they should. I hope It Helped you all. Sorry for my bad english still learning. Have a nice day..//Edit1 Tested. The Method with fake pivot is working fine, The Othermethod does some Strange bugs where rooms spawned Even If there was no Spawner.
@maximedumas175
@maximedumas175 3 жыл бұрын
hey, I think I have the same problem, but do I exactly change the pivot position of an existing object ? Thx for comment anyway, it helped !
@slynizz1014
@slynizz1014 6 жыл бұрын
Loved it! You the best Noa
@MobiusX
@MobiusX 8 ай бұрын
This tutorial is fine, but it has one major flaw. Sometimes you create rooms that have an exit to a locked room. You can't see it in the tutorial, because the rooms overlap each other. It's a shame because it doesn't work if you're going to use a tileset.
@Harri-yr8bp
@Harri-yr8bp 4 жыл бұрын
The spawn only occurs once and spawns just 4 rooms around it. Can someone help please!
@antzphilippinesph7205
@antzphilippinesph7205 4 жыл бұрын
Harri1000 Hello! Not sure if you fixed it yet, but I just fixed my problem after setting the Opening Directions of the room to their corresponding number for each spawnpoint
@jbrew1237
@jbrew1237 4 жыл бұрын
Did you make sure to set the openingDirection for all the spawn points? For every room?
@skullydev5710
@skullydev5710 2 жыл бұрын
It works well. But I have some rooms spawning in the Entry Room, and thus blocking all the paths from the entry room to the rest of the rooms. Edit: Ohh nvm XD just found video #3. Great tutorials bro. Keep it up
@martybonus728
@martybonus728 Жыл бұрын
this was really helpful for me. Very straightforward, totally approachable, and just what I needed. It is very easy to get FAR too much information about proc. gen, it seems -- and this was just the right level for my simple mind.
@askzmj
@askzmj Жыл бұрын
For those who have the infinite rooms problem, make sure that the middle of the room is in the smae spot as the empty parent object
@JoJam95
@JoJam95 5 ай бұрын
thank you stranger from a year ago! could not figure out why my rooms were spawning all over the place
@askzmj
@askzmj 5 ай бұрын
@@JoJam95 glad to help stranger from over 18 hours ago
@doublesystem9790
@doublesystem9790 6 жыл бұрын
Another awesome tutorial, this will really help me in the game i'm planning on make after the one for the contest! But there's a bug that i've seen and have no idea how to fix (it's fine if you also can't) that sometimes, a room can spawn with a door to another existing room that doesn't have a door in that direction so it ends having a door that goes into a wall. Still very good tutorial and as i've said, will help me a lot
@javedakhtar1435
@javedakhtar1435 6 жыл бұрын
Double System check the gameobjects put in the templates, even a single wrong placement can do wrong or check the spawnpoints rotation, it can give the same prob if the rotation is messy
@Blackthornprod
@Blackthornprod 6 жыл бұрын
Thanks, I'm really glad the tutorial is helping you :) ! Yes the door facing wall problem is annoying and I haven't found a simple solution to get rid of it ! What you could potentially do is have each wall shoot out a ray, and if there is a wall in front, then destroy the "door wall" and replace it with a normal wall. Hope that helps a little and best of luck :) !
@doublesystem9790
@doublesystem9790 6 жыл бұрын
Yeah, that's a good idea! Thanks
@javedakhtar1435
@javedakhtar1435 6 жыл бұрын
Blackthornprod HOLY MAMA THIS IS THE END OF MY PAIN !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *THIS IS THE FREAGING END OF MY LONG PAIN*
@khidayotullosalakhitdinov7485
@khidayotullosalakhitdinov7485 2 жыл бұрын
@@javedakhtar1435 Hi, if you still remember how, could you please show the way to solve this problem?
@haukrr_dev
@haukrr_dev 5 жыл бұрын
Hey! Nice video, Noa! But I wanna ask you if it's better to type in the code a switch instead of if and else if. Like switch(openingDirection) { case 1: r = Random.Range(0, templates.bottomrooms.Length); Instantiate(templates.bottomrooms[r], gameObject.transform.position, new Quaternion()); break; case 2: r = Random.Range(0, templates.toprooms.Length); Instantiate(templates.toprooms[r], gameObject.transform.position, new Quaternion()); break; case 3: r = Random.Range(0, templates.leftrooms.Length); Instantiate(templates.leftrooms[r], gameObject.transform.position, new Quaternion()); break; case 4: r = Random.Range(0, templates.rightrooms.Length); Instantiate(templates.rightrooms[r], gameObject.transform.position, new Quaternion()); break; } I think it's cleaner, but of course, anyone does it however it wants xD. PD: I'm sorry for my bad English, not's my native language but I hope you understood anyways :D
@mijkolsmith
@mijkolsmith 4 жыл бұрын
Had the exact same thought, and yeah seems cleaner to me
@hydrohomie254
@hydrohomie254 2 жыл бұрын
This is not only cleaner, but more efficient as well since it only checks openingDirection once instead of 4 times at worst with if else Statements.
@RM.-_-.
@RM.-_-. 4 жыл бұрын
Well... I followed this to best of my ability and now unity wont stop spawning rooms .... they dont spawn on the spawners there is so many....
@chrisdanikas7918
@chrisdanikas7918 6 жыл бұрын
Great work man.
@muratkk1096
@muratkk1096 4 жыл бұрын
great video. thanks for sharing your knowledge with us. your voices set my spirit on fire.
@theishiopian68
@theishiopian68 6 жыл бұрын
With regards to checking for adjacent rooms, wouldnt it be more efficient to create an array of booleans to represent the map and update it whenever a room is spawned? Then you could just check against that instead of using the physics system.
@fabi2816
@fabi2816 4 жыл бұрын
For some reason when i run it, the Rooms spawn but slightly off. I think it is because the Parent Game Object (For Example: B or BR) is off center. But i don´t know how i can get it centered because after adding the Spawnpoints it automatically changes.
@Happyhenzo
@Happyhenzo 2 жыл бұрын
I'm having the same problem but everything is lined up perfectly and I don't understand why they're spawning in the wrong positions. Did you fix it?
@reeceytaylor
@reeceytaylor 2 жыл бұрын
@@Happyhenzo For me, (I just fixed this issue) I had my spawn point game objects very slightly off in their prefabs. for example on my bottom one it was -0.97 instead of -1.
@TesloStep
@TesloStep 6 жыл бұрын
Sometimes this way of spawning goes wrong, for example 7:38 (right-top corner). Its on this cell two different rooms tried to spawn(one with the exit to the left, other with the exit to the right), but only one of them survive. Seems, there is no easy way to fix it, you need apply 2d array that stores, like, various stuff for every room - doors in that case.
@SociopathDev
@SociopathDev 5 жыл бұрын
i tryed to fix that problem but can't get it work, maybe someone knows how?
@TesloStep
@TesloStep 5 жыл бұрын
Rysian, well short answer: it's hard. Long answer - First of all, you need 32(=2^4) different room borders. Or, dunno, make room borders dynamically by combine north, south, west and east walls(where every wall can be solid or with doorway) - Then, you need a method to code every of your room type. I personally use binary system - (0b0000 - means there is no doors, 0b0001 means there is only north door, 0b1011 means there is all but south door). Yeah, I know, it's kinda counterintuitive as shit. And then, when your room intersects with other ( 6:36 ) you not just destroy one of them, but also do something like other.GetComponent().TypeCode |= TypeCode other.GetComponent().ResetBorders(); and add a new function public void ResetBorders() which pick a new door layout by your TypeCode for current Room object.
@raik1766
@raik1766 3 жыл бұрын
Hey, mine still overlaps even tought i added the OnTrigger function any idea why?
@shinewgamedev1525
@shinewgamedev1525 6 жыл бұрын
Thank You.
@oneway7122
@oneway7122 4 жыл бұрын
I followed the tutorial but my first few rooms spawn on top of each other I don't know why Edit: I saw Blackthronprod's comment now its all fixed :-)
@boeing-747
@boeing-747 5 жыл бұрын
There is a way to do this with tilemaps?
@TheBea314
@TheBea314 3 жыл бұрын
I did it creating the room with the tilemap... In the grid i did in one rectangular tilemap the room and in another rectangular tilemap the blocking element with tilemap collider
@nana_0427
@nana_0427 4 жыл бұрын
Thanks for your helping...!
@Ayman-fb7nq
@Ayman-fb7nq 2 жыл бұрын
Thanks for the tutorial! I tried to adapt this to 3D and I'm getting infinite rooms. I fixed my opening directions and also placed another spawn point in the center of the entry room set to 0, but the issue is still occurring. Everything is tagged properly. What might be happening?
@TheBu213
@TheBu213 2 жыл бұрын
Couple things it could be: there's no end room, so it keeps trying to add new rooms use OnTriggerEnter instead of OnTriggerEnter2D You might have the instantiate in a repeating method like update or the like those are the first 3 things that come to mind
@mimnimpetite8681
@mimnimpetite8681 4 жыл бұрын
I downloaded the GitHub version of this and got the same errors as when I followed the tutorial - NullReferenceException: Object reference not set to an instance of an object RoomSpawner.OnTriggerEnter2D (UnityEngine.Collider2D other) . I can only assume that this no longer works with the current version of Unity?
@someone242b5
@someone242b5 4 жыл бұрын
You don't need the unityengine.collider2d you just need collider2d
@nickablocka8822
@nickablocka8822 3 жыл бұрын
Did you get a fix? I have the same issue
@mimnimpetite8681
@mimnimpetite8681 3 жыл бұрын
Sorry, I never got it to work
@nickablocka8822
@nickablocka8822 3 жыл бұрын
@@mimnimpetite8681 its ok
@nickablocka8822
@nickablocka8822 3 жыл бұрын
@@someone242b5 what do you mean
@AdamMadejAnim
@AdamMadejAnim 6 жыл бұрын
Well Im stuck. Defined rand (like getting the number for which array element to spawn) gives me a nullexception. Idk why tho.
@sigorharaldsson4067
@sigorharaldsson4067 6 жыл бұрын
I'm having the same problem, how did you fix it? (if you did lol)
@Rioni
@Rioni 5 жыл бұрын
Thanks for the tutorial, I've learnt a lot! Btw your visual studio theme looks neat
@boeing-747
@boeing-747 5 жыл бұрын
It's not visual studio, it's monodevelop
@Rioni
@Rioni 5 жыл бұрын
@@boeing-747 Ups, what a mistake >
@zsdanix
@zsdanix 6 жыл бұрын
Seems a little wasteful to use a collider for that, but interesting concept :D
@purpleice2343
@purpleice2343 6 жыл бұрын
They go for simplicity instead of optimization, creating your own grid and managing it is a bit harder to do so they just went with it.
@abdullahamjad3612
@abdullahamjad3612 3 жыл бұрын
It Works For 3d As well Just Fix your Rooms Pivot Points at the software you use to create 3d Models
@craigsimons7882
@craigsimons7882 6 күн бұрын
It’s not spawning anything
@harleybekker
@harleybekker 5 жыл бұрын
thank you soooooo much you would not believe how much i needed this :))
@chronabigaming509
@chronabigaming509 5 жыл бұрын
Something always spawns on top of my main room please someone can help me??
@Hana_UwU
@Hana_UwU 4 жыл бұрын
look at the top of the commentry section
@gonubaxthefrench6144
@gonubaxthefrench6144 6 жыл бұрын
After adapting the code to a 3D world (it's kinda easy), i always get my rooms spawn again on the hall, then epilleptic amounts of light happens, walls on all exits and freezes Unity. Someone can help ? I think the collisions doesn't work, but i set them all to 3D instead of 2D. [Edit] : Okay, i was stupid : i forgot to set "Is Trigger" to true :/ But now everything's fine, the map generation is almost like i wanted :D
@ramadandu75
@ramadandu75 5 жыл бұрын
Would share your solution for the 3D world please? :)
@kevinguiboche2359
@kevinguiboche2359 6 жыл бұрын
How the heck does it know to spawn a room with the correct doors? The only time you mention it is when you declared it manually on the starting room
@ihatetheantichrist8043
@ihatetheantichrist8043 4 жыл бұрын
this is late but spawn points are only set on doors, meaning that rooms can only spawn where there are doors
@kevinguiboche2359
@kevinguiboche2359 4 жыл бұрын
@@ihatetheantichrist8043 yeah I realized that not too long after posting this question
@taylorseagrave3507
@taylorseagrave3507 4 жыл бұрын
My rooms only spawn once around each of the four sides of the original room and it doesn't expand past that. Anyone know how to fix this?
@krispyabroad
@krispyabroad 4 жыл бұрын
Do you have the script attached to your prefab as well as your entrance? The only reason I can see it happening is that the spawn points aren't correctly setup on your other rooms. Make sure all your spawn points are tagged correctly, have the "spawn room" script with the direction specified as the corresponding number, and that should do the trick. Else, your best bet is to clone the project from github and review where things went wrong
@taylorseagrave3507
@taylorseagrave3507 4 жыл бұрын
Krispy Jin Ok I’ll try that, thx!
@Aboutpizza
@Aboutpizza 2 жыл бұрын
Very big Thank you
@mjmedits3486
@mjmedits3486 5 жыл бұрын
I've made everything cOrReCtLy but the rooms do not spawn. I'm big sad.
@swapty7860
@swapty7860 4 жыл бұрын
Somebody?
@tinyduccgames7667
@tinyduccgames7667 4 жыл бұрын
I doubt you'll see this comment but if you do, I followed your code correctly and still I only get 4 outer rooms and on some cases overlapping on the pieces. Is the code just out of date or is it something else?
@zombeatzmedia6101
@zombeatzmedia6101 4 жыл бұрын
Did you go edit the prefabs and make sure that all room spawners have the corresponding number? That was the first issue i had
@joshuamurphy2020
@joshuamurphy2020 4 жыл бұрын
Mine were spawning in a big scramble and not connecting with eachother. The reason is because when I built my rooms, I didn't make sure that 0,0 on my object was in the center of my walls. In other words, my walls weren't built surrounding the room GameObject. Realigning my walls and spawners so that each spawner has a relative coordinate of 10 , -10 or 0 on any axis fixed the problem.
@thegoodbuddy1550
@thegoodbuddy1550 3 жыл бұрын
can you please tell me how to make sure that 0,0 on object is in the center of the walls
@magdymaher9700
@magdymaher9700 6 жыл бұрын
Thanks a lot for smart tutorials
@Baconloord
@Baconloord Жыл бұрын
If youre rooms spawn infinitely check that all your spawnpoints have their box collider "is trigger" checked mine didnt after copying them
@asherhill6477
@asherhill6477 6 жыл бұрын
I am receiving this error: NullReferenceException: Object reference not set to an instance of an object RoomSpawner.Spawn () (at Assets/Scripts/RoomSpawner.cs:44) in reference to each of the lines like this: rand = Random.Range(0, templates.leftRooms.Length); I did include this line at the top: templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent(); So I don't know whats gone wrong. Any ideas?
@asherhill6477
@asherhill6477 6 жыл бұрын
For anyone else who is stuck here, I didn't set the RoomTemplates tag to rooms.
@thekiubec7108
@thekiubec7108 4 жыл бұрын
@@asherhill6477 LIFE SAVER THANK YOU
@oogaboga6131
@oogaboga6131 Жыл бұрын
people that are having problems with it spawning inf rooms and crashing unity, heres how i fixed it: Add a max num of rooms to you room template script. And in the roomSpawner script, increment it after all the ifs in the spawn functions. Also I deleted the spawn points from the dead ends because there is no points in keeping them as no rooms should spawn there,
@GoddessOfSpring
@GoddessOfSpring 4 жыл бұрын
It's saying that I need to add a null check for "templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent();" Any help?
@generic5137
@generic5137 4 жыл бұрын
add a null check for "templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent();" its telling you to do that because templates would throw a nullexception error without it i think
@adrianthefrog
@adrianthefrog 4 жыл бұрын
That's weird. Checks should be optional. Try this: if(GameObject.FindGameObjectWithTag("Rooms").GetComponent() != null) { templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent() } But also make sure: 1. There is only one Gameobject with the tag "Rooms" 2. It has a script attached named "RoomTemplates"
@tuxfoss1944
@tuxfoss1944 3 жыл бұрын
i have similar problem , i get "The type or namespace name 'RoomTemplates' could not be found (are you missing a using directive or an assembly reference?" any help ? :)
@aee8410
@aee8410 6 жыл бұрын
God dammit every time i run it i get 4 weirdly placed rooms on each side of the starting room, checked the spawning points to see if maybe i kinda misplaced them but no they seemed pretty good so i have no idea what could be messed up abput the weird placement. Checked the code too to see if i missed something that makes it only spawn 4 new rooms, do you have any idea what could be causing such thing? Edit: Hey well maybe you are busy or just won't see this anyways but i wanted to ask that are you suppsed to give a number to each RoomSpawner script on the Spawn Point game objects?(I'm not sure since you just numbered the main entry rooms spawn points) Would love if you could reply
@Seanld98
@Seanld98 6 жыл бұрын
From what I did, you are supposed to put the Opening direction variable for every spawner on EVERY intersection, not just on the Entry Map, but all of them. L, TL, etc
@SamNBCA
@SamNBCA 6 жыл бұрын
Make sure there is a spawnpoint at the very center of your starting room ( i had missed that)
@noahsimonson6571
@noahsimonson6571 4 жыл бұрын
mine only spawns a room on each side of the main room, and they are all off center and overlapping
@parkercarron4940
@parkercarron4940 4 жыл бұрын
You have to set the open direction int for all of the rooms
@Hxkuu_
@Hxkuu_ 4 жыл бұрын
It does not spawn the rooms? Help? It says "NullReferenceException: Object reference not set to an instance of an object RoomSpawner.Spawn () (at Assets/RoomSpawner.cs:36)"
@roweenplays
@roweenplays 4 жыл бұрын
found ya
@leonhartmann3424
@leonhartmann3424 4 жыл бұрын
Do You have a solution now?
@Hxkuu_
@Hxkuu_ 4 жыл бұрын
Leon Hartmann yep
@leonhartmann3424
@leonhartmann3424 4 жыл бұрын
What is the solution? have the same problem :(
@Hxkuu_
@Hxkuu_ 4 жыл бұрын
@@leonhartmann3424 i will give you my code, just wait(Dont mind the names that i have given)
@rowandee3470
@rowandee3470 2 жыл бұрын
Does anyone know if there is a way where you can set the number of rooms you want in the dungeon, like if you wanted a dungeon with 50 rooms it would stop generating after 50?
@claws61821
@claws61821 2 жыл бұрын
You'll have to rearrange some of the code to make use of it, but essentially what you want to do is to iterate the creation code through a For Loop until the variable that you use to track the iteration hits 50 (or other desired limit).
@felipezymor9970
@felipezymor9970 2 жыл бұрын
It would be good to set a minimum amount of rooms too, sometimes it spawns tiny dungeons (about 10 rooms) and sometimes it spawns dungeons with 20 rooms... If someone figures out how to make a minimum and maximum room amount, it would be great if you share with us
@bicasualtea7563
@bicasualtea7563 4 жыл бұрын
my console brings up the issue of “NullRefrenceExeption: Object reference not set to an instance of an object RoomSpawner.Spawn () (at Assets/scripts/RoomSpawner.cs:23)
@Noah1377
@Noah1377 4 жыл бұрын
Some variable seems to not be properly assigned. Can you provide some of the actual code?
@RaisingX
@RaisingX 5 жыл бұрын
Where is declared how many rooms can spawn or is it always a random number, since they keep spawning as long there is an open door and no edge ?
@Alessandro-lx1ug
@Alessandro-lx1ug 3 жыл бұрын
its random
@michaelsantamaria8306
@michaelsantamaria8306 4 жыл бұрын
stuff just spawns on top of each other and not by a door
@Mycrosss
@Mycrosss 5 жыл бұрын
Weird way to tackle this, wouldn't you usually just make one function that handles the entire map spawning which you would call at the start? This seems like a way more confussing and round-about way of going at it, but oh well
@sigorharaldsson4067
@sigorharaldsson4067 6 жыл бұрын
This doesn't work for me, It only comes up with an error that says: Object reference not set to an instance of an object, does anybody know how to fix this?
@elefents24
@elefents24 3 жыл бұрын
There is an offset on my spawn point position that is causing the rooms to be misplaced and the rooms are spawning infinitely. Does anyone know what could be causing this?
@frostbite9356
@frostbite9356 2 жыл бұрын
this may be a little late, but your prefab objects are are not centered correctly.
@danc01
@danc01 2 жыл бұрын
@@frostbite9356 I'm having this issue, centered how? Could you explain what you mean? Thanks
@diavolo6433
@diavolo6433 4 жыл бұрын
There aren't any rooms spawning. Does anyone know what could help?
@Spider0Music
@Spider0Music 2 жыл бұрын
The line that defines the variable templates does not work, please fix!!!!
@jrmillerfilms
@jrmillerfilms 2 жыл бұрын
It does work, just make sure you are writing it in the proper place. Make sure its inside the { } for public class RoomSpawner : MonoBehavior and that is is not inside any other { }. Also make sure that when you write it out it matches the other script's name you made. There may be a spelling inconsistency.
@aslanmussayev5243
@aslanmussayev5243 6 жыл бұрын
it keeps spawning rooms even there is no spawn points. anyone faced this problem? what im doing wrong? It even changes the existing rooms(
@oneuppings3270
@oneuppings3270 5 жыл бұрын
If this was your intention, then this would make for a really difficult maze game.
@glez3711
@glez3711 4 жыл бұрын
Hi Blackthornprod! Does this random dungeon generator work in a 3D environment?
@Old_SDC
@Old_SDC 3 жыл бұрын
I’m not getting any errors but nothing is spawning? All of the opening directions are set properly (on all prefabs and current objects) and the “Spawned” value isn’t checked (I’ve tried checked and unchecked) please help
@angelicus-9307
@angelicus-9307 Жыл бұрын
probably not many people here, but i have issues. 1. The program runs but no rooms spawn. Im trying to figure out why, any guesses is helpful. (im getting no error messages). 2. I dont get GameObject and others as a "quick choices" and no colorcode. Doesnt impact the code itself i guess. But its annoying when the colorcoding isnt working on some parts. But on others it works fine (like "public int" is blue)
@angelicus-9307
@angelicus-9307 Жыл бұрын
Well, finally after 3 days figured out the problem. "Start" is case-sensitive.... so yeah.... feel very smart. Now i have infinite room. So another issue to solve. Luckily suggestions already exist in the comments so ill see if my solution is there
@angelicus-9307
@angelicus-9307 Жыл бұрын
Okey, think the infinite room is solved. Now... How do i make two rooms that have doors to the same "Square" spawn a room, and that room having doors to both directions? Thats a problem now
@TheCrushiii
@TheCrushiii Жыл бұрын
Hey I got the same issue as you, no error but no spawning at all, nothing happens, how did you do to fix the issue exactly ? Thanks for your help@@angelicus-9307
@oisinoconnell1380
@oisinoconnell1380 3 жыл бұрын
Can someone help please At first I had the problem of infinite spawning rooms and they where over lapping each other but after looking at my code again I realised I had a capital in a place it shouldn't have been when stating CompareTag("SpawnPoint") Destroy (gameObject) After fixing that problem I now cant get anything to spawn, I have confirmed that it is now the right tag and that if I put in the wrong tag it infinity spawns rooms so dose anyone have any advice for me on what the issue could be ?
@oisinoconnell1380
@oisinoconnell1380 3 жыл бұрын
I solved my problem the box colliders where just bearly touching each other so they ended up destroying themselves as soon as they where made
@williamwimberly6882
@williamwimberly6882 3 жыл бұрын
What happened to BL?
@killogee1899
@killogee1899 3 жыл бұрын
i did everything correct but when i clicked play it spawed 1 room that's merged in top right corner of starting room
@fatih7397
@fatih7397 7 ай бұрын
I have read all the comments about infinite spawn but non of them have solved my problem. My rooms are spawning infinite but always on the top side. How do i solve this? Thank you very much.
@DukeFishron-mq1ir
@DukeFishron-mq1ir 7 ай бұрын
I will check and help you out when i get the answer
@danc01
@danc01 2 жыл бұрын
This is a great tutorial for 2018 but doesn't work with 2022. As soon as you add the box collider 2d and rigidbody the pivot point changes. Once this happens your maze spawns separate themselves by 1 unit. I've worked on many solutions for this and I haven't come up with a viable solution.
@albertozp
@albertozp Жыл бұрын
Make sure you have the "Toogle Tool Hand Position" (top left corner in the "Scene" window" set to "Pivot" instead of "Center"
@ir3dy976
@ir3dy976 6 жыл бұрын
Can you talk and or show us how to add enviorment hazords to each room at different amounts like u see in binding of issac..?? Random enemy spawn and random item/ enviorment pieces spawn??
@doublesystem9790
@doublesystem9790 6 жыл бұрын
iR3dy in the binding of isaac, the enemies, chests, rocks, poops and this kinda stuff in a room aren't random. Each room in isaac was pre-made and the only really random things are tinted rocks and some of the enemie's movements so, to do stuff like in the binding of isaac just make a bunch more rooms with the rocks and enemy spawnners and wathever you want in them and put the rooms in the 4 arrays
@javedakhtar1435
@javedakhtar1435 6 жыл бұрын
alternatively, u can watch blackthornprod's precedural generation vid and use that in the rooms
@ir3dy976
@ir3dy976 6 жыл бұрын
Devil Bunny Games - GameDev but how would i optimize it so iys not so data/ frame heavy? And add it to the rooms? Instead of the whole scene? Making it area specific?
@Blackthornprod
@Blackthornprod 6 жыл бұрын
True enough, in the binding of isaac rooms are 'pre-made' BUT if you do want random stuff in each room check out this video I made a few weeks ago : kzbin.info/www/bejne/emWogJqQrrOeY80 Hope that helps :) !
@javedakhtar1435
@javedakhtar1435 6 жыл бұрын
iR3dy iR3dy just think like this every room will have an array of item spawner (like the spawner that btp made, he just shared the link) then instantiate randomly any of the item spawner, and that item spawner will instantiate objects in the room, and this definately wont be system heavy bc there wont be any other rigid bodies/colliders except the instantiated objects also, u can destroy the spawner after it has spawned the objects to save a lil amount of memory (it did alot good for me though) hope that helps :happyprod:
@bruceslater7204
@bruceslater7204 6 жыл бұрын
GOOD TIMES :D
@swapty7860
@swapty7860 4 жыл бұрын
2019 someone can tell me why it spawned just 4 rooms any time
@acuencadev
@acuencadev 4 жыл бұрын
Did you set the openingDirection property to a 1-4 value for each prefab?
@bicasualtea7563
@bicasualtea7563 4 жыл бұрын
mine doesnt spawn anything
@patientpanda7206
@patientpanda7206 3 жыл бұрын
Hey wonderful video! just wanted to ask how to get the code to spawn more than just the first set of rooms around the spawnroom. The issue is the code will only spawn the 4 rooms at the start then stop
@NormalHuman5
@NormalHuman5 Жыл бұрын
Code doesn't work, it shows NullReferenceException. Can somebody help me?
@trevornaumann9011
@trevornaumann9011 4 жыл бұрын
What's the purpose of Invoke? This sript is attached to each spawn point right? So once Spawn() is called wouldn't the rooms it spawns (and there respective spawn points) then spawn more rooms and so on? Does Invoke() serve the purpose of keeping the object active so you can access it's properties when needed?
@krispyabroad
@krispyabroad 4 жыл бұрын
Since we're generating a map, we have rules to follow. If you spawn it on start then the rules haven't been set if you know what I mean. So if you test it as "Spawn();" without an invoke, then it generates a map, but it spawns it in an unorganised way without a clear path or no path atoll as it just generates without clear rules. But invoke gives it time to think, so you place the first set and then it decides if the next room can be places there or not. Hope that helps pal
@chaosmastermind
@chaosmastermind 2 жыл бұрын
Wouldn't there be the possibility of it spawning infinite rooms since there is nothing stopping it from doing so?
@jrmillerfilms
@jrmillerfilms 2 жыл бұрын
void OnTriggerEnter2D(Collider2D coll) { if(coll.CompareTag("SpawnPoint")) Destroy(gameObject); } This method is written outside of the Spawn method. So when it detects another spawnpoint trying to position itself there it destroys it.
@thesrb2fan12
@thesrb2fan12 Жыл бұрын
This is great
@advecide
@advecide 6 жыл бұрын
Does anyone know a tutorial on how to make a map with this, like with the binding of Isaac, the map that you walk around is the same as the mini map
@niksprint7776
@niksprint7776 5 жыл бұрын
I think this tutorial kzbin.info/www/bejne/oYjLgICAgs6beZI will be pretty good for that (i know it's late to answer but, maybe someone will have the same question and will notice your comment, just as my answer)
@jacobgallow4960
@jacobgallow4960 4 жыл бұрын
Please help! I keep getting infinite overlapping rooms spawning. I have followed every instruction carefully and have spent much time looking through the comments and trying those suggested fixes. I got gamedev to create a game like binding of issaac, please help with haste!!!!!!
@Phamility
@Phamility 4 жыл бұрын
Figure it out? Because adding a global room limit variable leads it openings so I also need help :p
@kbenskeer5071
@kbenskeer5071 4 жыл бұрын
i have the same problem, have you fixed it?
@firebubble2
@firebubble2 3 жыл бұрын
It just won't work
@firebubble2
@firebubble2 3 жыл бұрын
OK so i added an empty in the middle of each unique room, gave it the RoomSpawner script with the value 0 and added "&& openingDirection != 0" into the ontriggerenter2d if statement RoomSpawner object called "Mid", with opening direction = 0 if (other.CompareTag("RoomSpawn") && openingDirection != 0) { Destroy(gameObject); }
@nickablocka8822
@nickablocka8822 3 жыл бұрын
I have a error NullReferenceException: Object reference not set to an instance of an object RoomSpawner.OnTriggerEnter2D (UnityEngine.Collider2D other) (at Assets/Scripts/RoomSpawner.cs:53) The code : using System.Collections; using System.Collections.Generic; using UnityEngine; public class RoomSpawner : MonoBehaviour { public int openingDirection; // 1 --> need bottom door // 2 --> need top door // 3 --> need left door // 4 --> need right door private RoomTemplates templates; private int rand; private bool spawned = false; public float waitTime = 4f; void Start(){ Destroy(gameObject, waitTime); templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent(); Invoke("Spawn", 0.1f); } void Spawn(){ if(spawned == false){ if(openingDirection == 1){ // Need to spawn a room with a BOTTOM door. rand = Random.Range(0, templates.bottomRooms.Length); Instantiate(templates.bottomRooms[rand], transform.position, templates.bottomRooms[rand].transform.rotation); } else if(openingDirection == 2){ // Need to spawn a room with a TOP door. rand = Random.Range(0, templates.topRooms.Length); Instantiate(templates.topRooms[rand], transform.position, templates.topRooms[rand].transform.rotation); } else if(openingDirection == 3){ // Need to spawn a room with a LEFT door. rand = Random.Range(0, templates.leftRooms.Length); Instantiate(templates.leftRooms[rand], transform.position, templates.leftRooms[rand].transform.rotation); } else if(openingDirection == 4){ // Need to spawn a room with a RIGHT door. rand = Random.Range(0, templates.rightRooms.Length); Instantiate(templates.rightRooms[rand], transform.position, templates.rightRooms[rand].transform.rotation); } spawned = true; } } void OnTriggerEnter2D(Collider2D other){ if(other.CompareTag("SpawnPoint")){ if(other.GetComponent().spawned == false && spawned == false){ Instantiate(templates.closedRoom, transform.position, Quaternion.identity); Destroy(gameObject); } spawned = true; } } } please help :(
@Mafi4Wolfy
@Mafi4Wolfy 2 жыл бұрын
Did everything as instructed, had issues so i fixed them but anytime i try testing it, it spawns 4 random rooms and they are not connected, they are kinda all over the place if not one or two overlaying the main room, i used rigidbody 2D as well as the BoxColliders, please help?
@supa_skelly3944
@supa_skelly3944 4 жыл бұрын
The first set of rooms keeps spawning off centered and I can't figure out why
@oneway7122
@oneway7122 4 жыл бұрын
Hi so Blackthronprod commented that the end of the if statement && other.GameObject.GetComponent().spawned == true should not be writen I had the same problem and that fixed it hope that helped :-)
@supa_skelly3944
@supa_skelly3944 4 жыл бұрын
@@oneway7122 I think my new rooms are spawning from their pivot point instead of their center but I dont know how to fix it
@oneway7122
@oneway7122 4 жыл бұрын
@@supa_skelly3944 assuming that you put your rooms inside of an empty gameobject do you have your gameobject at the center of your room?
@supa_skelly3944
@supa_skelly3944 4 жыл бұрын
@@oneway7122 I realized I hadnt put them in an empty gameobject yet, just did it and it worked! Tysm! :D
@oneway7122
@oneway7122 4 жыл бұрын
@@supa_skelly3944 no problem man
@danteps13
@danteps13 6 жыл бұрын
Hey, so I got to the end of the video and went to check if everything was working, however when I pressed play it spawned 4 rooms which were not connected and were spread out all over the place. I think they are in the places I used to put all of the spawnpoints with each of the different rooms but here has been once where 3 connected together without a middle part (this would be the starting area). Can anyone help soon, because I really want to do this quickly and move on to enemies?
@Alessandro-lx1ug
@Alessandro-lx1ug 3 жыл бұрын
did you fix it?
@danteps13
@danteps13 3 жыл бұрын
@@Alessandro-lx1ug I eventually solved it a different way, but thanks for asking
@Alessandro-lx1ug
@Alessandro-lx1ug 3 жыл бұрын
@@danteps13 could you please tell me how, i have this exact problem
@danteps13
@danteps13 3 жыл бұрын
@@Alessandro-lx1ug i dont remember, it was over 2 years ago
@Alessandro-lx1ug
@Alessandro-lx1ug 3 жыл бұрын
@@danteps13 yeah thats logique welp thanks anyway
@adrijanascesna6528
@adrijanascesna6528 Жыл бұрын
i cant get any of the rooms to spawn i am using 3d so i am using the normal collider and rigidbody but everything i have tried hasn't work, I'm not getting any errors as well, would love some help
@jayshah6056
@jayshah6056 5 жыл бұрын
Nothing spawns it doesn't show any error in editor so good is right also it is exact copy as yours but still nothing is generated ... Just one middle room =(
@craigsimons7882
@craigsimons7882 6 күн бұрын
My rooms aren’t spawning
@ArcadeShow
@ArcadeShow 2 жыл бұрын
Followed every single step, exactly and just keep encountering error after error.
@sethhoule3705
@sethhoule3705 Жыл бұрын
Little Late but you need to write it as int rand = Randomd.Range(your code):
RANDOM DUNGEON GENERATION - EASY UNITY TUTORIAL - #3
8:29
Blackthornprod
Рет қаралды 110 М.
A new way to generate worlds (stitched WFC)
10:51
Watt Designs
Рет қаралды 532 М.
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26
Which One Is The Best - From Small To Giant #katebrush #shorts
00:17
Learning C# In A Week... Otherwise I Fail University
9:04
I rewrote my dungeon generator!
4:27
UnitOfTime
Рет қаралды 160 М.
7 DEVS Make a GAME without COMMUNICATING! (we never saw this coming)
20:12
I Bullied this AI into Learning Parkour
11:12
cozmouz
Рет қаралды 34 М.
Procedurally Generated 3D Dungeons
9:42
Vazgriz
Рет қаралды 289 М.
Making a Game With C++ and SDL2
8:14
PolyMars
Рет қаралды 1,7 МЛН
What size should your assets be? | HD 2D GAME ART
12:10
Nonsensical 2D
Рет қаралды 130 М.
How I Learned Procedural Generation
5:36
Lejynn
Рет қаралды 265 М.
The Trick I Used to Make Combat Fun! | Devlog
8:12
Game Endeavor
Рет қаралды 1,7 МЛН
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,1 МЛН
Minecraft Creeper Family is back! #minecraft #funny #memes
00:26