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 !
@Blackthornprod6 жыл бұрын
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 :) !
@lhenardabraham90686 жыл бұрын
It spawns unlimited rooms :O
@Sebastian-vx6jc5 жыл бұрын
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
@Braderzian5 жыл бұрын
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-rl64185 жыл бұрын
@@cornflakestoasted I just faced this issue bro, make sure there's no Spawnpoint on the Closed room
@memoal-said51112 жыл бұрын
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.
@christinaVennegerts2 жыл бұрын
Oh, finally! This one worked for me, thank you so much =)!
@quoctrungtran6403 Жыл бұрын
U Saved me
@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)
@valeryisfreedom10 ай бұрын
🤩
@eribetra2 жыл бұрын
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.
@tatepayton73682 жыл бұрын
That fixed it!
@change99072 жыл бұрын
God bless you. Thank you. I was just about to close unity.
@ncpokemonfan4 жыл бұрын
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.24813 жыл бұрын
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?
@Phamility4 жыл бұрын
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
@kbenskeer50714 жыл бұрын
doesnt work for me :(
@criticalhitentertainment4 жыл бұрын
Thanks! That helped me a lot!
@dorieta_gaming2 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
welcome
@husk1605 жыл бұрын
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 ♥️
@micaiahstevens88406 жыл бұрын
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.
@micaiahstevens88406 жыл бұрын
Of course I wrote all the meta data by hand, but I could scan the picture and find the doors.
@felipezymor99702 жыл бұрын
Can you share with us the code?
@NPOCrushader5 жыл бұрын
Not sure why. But my rooms keep spawning infinite.
@oliverscott69134 жыл бұрын
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
@st41n3d24 жыл бұрын
@@oliverscott6913 Thank you for this
@Cvile694 жыл бұрын
@@oliverscott6913 OOOOOOOOOOOOOOOOOOOOOH GOD DAMN IT thanks
@Cprime383 жыл бұрын
For future people, don't forget to tag Spawn points too.
@lyrick36033 жыл бұрын
@@oliverscott6913 I love you, you just saved me.
@NotifrikiTV2 жыл бұрын
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_MTGA4 жыл бұрын
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.
@zombievirals6 жыл бұрын
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!! :)
@YasserSedrati6 жыл бұрын
at some point moment i was thinking i am watching "Brackeys" haha, *your videos in progress!*
@luciorojas42784 жыл бұрын
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
@itsspider61564 жыл бұрын
I don't understand, what 2d colliders?? the box collider?
@javedakhtar14356 жыл бұрын
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 😀
@Blackthornprod6 жыл бұрын
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 :) !
@javedakhtar14356 жыл бұрын
Blackthornprod trying to wait 😁
@bunggo99146 жыл бұрын
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
@sohaybalnajjar49684 жыл бұрын
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 .
@thegoodbuddy15503 жыл бұрын
hey mate i know its been 10 months but have you found a solution for the first problem
@sohaybalnajjar49683 жыл бұрын
@@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
@sohaybalnajjar49683 жыл бұрын
@@thegoodbuddy1550 i can remember there was a solution on the internet either unity Q&A or youtube
@thegoodbuddy15503 жыл бұрын
@@sohaybalnajjar4968 ohh yea i think i found the problem thanks for your help
@sinningchickenco.24813 жыл бұрын
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
@orrianicon14285 жыл бұрын
Now noticing rooms spawning on top of my entry room. Cutting off doorways out.
@MidoriLetsPlay4 жыл бұрын
Have you found a fix?
@krispyabroad4 жыл бұрын
@@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
@hellxsan4 жыл бұрын
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.
@maximedumas1753 жыл бұрын
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 !
@slynizz10146 жыл бұрын
Loved it! You the best Noa
@MobiusX8 ай бұрын
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-yr8bp4 жыл бұрын
The spawn only occurs once and spawns just 4 rooms around it. Can someone help please!
@antzphilippinesph72054 жыл бұрын
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
@jbrew12374 жыл бұрын
Did you make sure to set the openingDirection for all the spawn points? For every room?
@skullydev57102 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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
@JoJam955 ай бұрын
thank you stranger from a year ago! could not figure out why my rooms were spawning all over the place
@askzmj5 ай бұрын
@@JoJam95 glad to help stranger from over 18 hours ago
@doublesystem97906 жыл бұрын
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
@javedakhtar14356 жыл бұрын
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
@Blackthornprod6 жыл бұрын
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 :) !
@doublesystem97906 жыл бұрын
Yeah, that's a good idea! Thanks
@javedakhtar14356 жыл бұрын
Blackthornprod HOLY MAMA THIS IS THE END OF MY PAIN !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! *THIS IS THE FREAGING END OF MY LONG PAIN*
@khidayotullosalakhitdinov74852 жыл бұрын
@@javedakhtar1435 Hi, if you still remember how, could you please show the way to solve this problem?
@haukrr_dev5 жыл бұрын
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
@mijkolsmith4 жыл бұрын
Had the exact same thought, and yeah seems cleaner to me
@hydrohomie2542 жыл бұрын
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.-_-.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....
@chrisdanikas79186 жыл бұрын
Great work man.
@muratkk10964 жыл бұрын
great video. thanks for sharing your knowledge with us. your voices set my spirit on fire.
@theishiopian686 жыл бұрын
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.
@fabi28164 жыл бұрын
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.
@Happyhenzo2 жыл бұрын
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?
@reeceytaylor2 жыл бұрын
@@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.
@TesloStep6 жыл бұрын
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.
@SociopathDev5 жыл бұрын
i tryed to fix that problem but can't get it work, maybe someone knows how?
@TesloStep5 жыл бұрын
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.
@raik17663 жыл бұрын
Hey, mine still overlaps even tought i added the OnTrigger function any idea why?
@shinewgamedev15256 жыл бұрын
Thank You.
@oneway71224 жыл бұрын
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-7475 жыл бұрын
There is a way to do this with tilemaps?
@TheBea3143 жыл бұрын
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_04274 жыл бұрын
Thanks for your helping...!
@Ayman-fb7nq2 жыл бұрын
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?
@TheBu2132 жыл бұрын
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
@mimnimpetite86814 жыл бұрын
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?
@someone242b54 жыл бұрын
You don't need the unityengine.collider2d you just need collider2d
@nickablocka88223 жыл бұрын
Did you get a fix? I have the same issue
@mimnimpetite86813 жыл бұрын
Sorry, I never got it to work
@nickablocka88223 жыл бұрын
@@mimnimpetite8681 its ok
@nickablocka88223 жыл бұрын
@@someone242b5 what do you mean
@AdamMadejAnim6 жыл бұрын
Well Im stuck. Defined rand (like getting the number for which array element to spawn) gives me a nullexception. Idk why tho.
@sigorharaldsson40676 жыл бұрын
I'm having the same problem, how did you fix it? (if you did lol)
@Rioni5 жыл бұрын
Thanks for the tutorial, I've learnt a lot! Btw your visual studio theme looks neat
@boeing-7475 жыл бұрын
It's not visual studio, it's monodevelop
@Rioni5 жыл бұрын
@@boeing-747 Ups, what a mistake >
@zsdanix6 жыл бұрын
Seems a little wasteful to use a collider for that, but interesting concept :D
@purpleice23436 жыл бұрын
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.
@abdullahamjad36123 жыл бұрын
It Works For 3d As well Just Fix your Rooms Pivot Points at the software you use to create 3d Models
@craigsimons78826 күн бұрын
It’s not spawning anything
@harleybekker5 жыл бұрын
thank you soooooo much you would not believe how much i needed this :))
@chronabigaming5095 жыл бұрын
Something always spawns on top of my main room please someone can help me??
@Hana_UwU4 жыл бұрын
look at the top of the commentry section
@gonubaxthefrench61446 жыл бұрын
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
@ramadandu755 жыл бұрын
Would share your solution for the 3D world please? :)
@kevinguiboche23596 жыл бұрын
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
@ihatetheantichrist80434 жыл бұрын
this is late but spawn points are only set on doors, meaning that rooms can only spawn where there are doors
@kevinguiboche23594 жыл бұрын
@@ihatetheantichrist8043 yeah I realized that not too long after posting this question
@taylorseagrave35074 жыл бұрын
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?
@krispyabroad4 жыл бұрын
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
@taylorseagrave35074 жыл бұрын
Krispy Jin Ok I’ll try that, thx!
@Aboutpizza2 жыл бұрын
Very big Thank you
@mjmedits34865 жыл бұрын
I've made everything cOrReCtLy but the rooms do not spawn. I'm big sad.
@swapty78604 жыл бұрын
Somebody?
@tinyduccgames76674 жыл бұрын
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?
@zombeatzmedia61014 жыл бұрын
Did you go edit the prefabs and make sure that all room spawners have the corresponding number? That was the first issue i had
@joshuamurphy20204 жыл бұрын
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.
@thegoodbuddy15503 жыл бұрын
can you please tell me how to make sure that 0,0 on object is in the center of the walls
@magdymaher97006 жыл бұрын
Thanks a lot for smart tutorials
@Baconloord Жыл бұрын
If youre rooms spawn infinitely check that all your spawnpoints have their box collider "is trigger" checked mine didnt after copying them
@asherhill64776 жыл бұрын
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?
@asherhill64776 жыл бұрын
For anyone else who is stuck here, I didn't set the RoomTemplates tag to rooms.
@thekiubec71084 жыл бұрын
@@asherhill6477 LIFE SAVER THANK YOU
@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,
@GoddessOfSpring4 жыл бұрын
It's saying that I need to add a null check for "templates = GameObject.FindGameObjectWithTag("Rooms").GetComponent();" Any help?
@generic51374 жыл бұрын
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
@adrianthefrog4 жыл бұрын
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"
@tuxfoss19443 жыл бұрын
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 ? :)
@aee84106 жыл бұрын
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
@Seanld986 жыл бұрын
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
@SamNBCA6 жыл бұрын
Make sure there is a spawnpoint at the very center of your starting room ( i had missed that)
@noahsimonson65714 жыл бұрын
mine only spawns a room on each side of the main room, and they are all off center and overlapping
@parkercarron49404 жыл бұрын
You have to set the open direction int for all of the rooms
@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)"
@roweenplays4 жыл бұрын
found ya
@leonhartmann34244 жыл бұрын
Do You have a solution now?
@Hxkuu_4 жыл бұрын
Leon Hartmann yep
@leonhartmann34244 жыл бұрын
What is the solution? have the same problem :(
@Hxkuu_4 жыл бұрын
@@leonhartmann3424 i will give you my code, just wait(Dont mind the names that i have given)
@rowandee34702 жыл бұрын
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?
@claws618212 жыл бұрын
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).
@felipezymor99702 жыл бұрын
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
@bicasualtea75634 жыл бұрын
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)
@Noah13774 жыл бұрын
Some variable seems to not be properly assigned. Can you provide some of the actual code?
@RaisingX5 жыл бұрын
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-lx1ug3 жыл бұрын
its random
@michaelsantamaria83064 жыл бұрын
stuff just spawns on top of each other and not by a door
@Mycrosss5 жыл бұрын
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
@sigorharaldsson40676 жыл бұрын
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?
@elefents243 жыл бұрын
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?
@frostbite93562 жыл бұрын
this may be a little late, but your prefab objects are are not centered correctly.
@danc012 жыл бұрын
@@frostbite9356 I'm having this issue, centered how? Could you explain what you mean? Thanks
@diavolo64334 жыл бұрын
There aren't any rooms spawning. Does anyone know what could help?
@Spider0Music2 жыл бұрын
The line that defines the variable templates does not work, please fix!!!!
@jrmillerfilms2 жыл бұрын
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.
@aslanmussayev52436 жыл бұрын
it keeps spawning rooms even there is no spawn points. anyone faced this problem? what im doing wrong? It even changes the existing rooms(
@oneuppings32705 жыл бұрын
If this was your intention, then this would make for a really difficult maze game.
@glez37114 жыл бұрын
Hi Blackthornprod! Does this random dungeon generator work in a 3D environment?
@Old_SDC3 жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
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
@oisinoconnell13803 жыл бұрын
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 ?
@oisinoconnell13803 жыл бұрын
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
@williamwimberly68823 жыл бұрын
What happened to BL?
@killogee18993 жыл бұрын
i did everything correct but when i clicked play it spawed 1 room that's merged in top right corner of starting room
@fatih73977 ай бұрын
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-mq1ir7 ай бұрын
I will check and help you out when i get the answer
@danc012 жыл бұрын
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 Жыл бұрын
Make sure you have the "Toogle Tool Hand Position" (top left corner in the "Scene" window" set to "Pivot" instead of "Center"
@ir3dy9766 жыл бұрын
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??
@doublesystem97906 жыл бұрын
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
@javedakhtar14356 жыл бұрын
alternatively, u can watch blackthornprod's precedural generation vid and use that in the rooms
@ir3dy9766 жыл бұрын
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?
@Blackthornprod6 жыл бұрын
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 :) !
@javedakhtar14356 жыл бұрын
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:
@bruceslater72046 жыл бұрын
GOOD TIMES :D
@swapty78604 жыл бұрын
2019 someone can tell me why it spawned just 4 rooms any time
@acuencadev4 жыл бұрын
Did you set the openingDirection property to a 1-4 value for each prefab?
@bicasualtea75634 жыл бұрын
mine doesnt spawn anything
@patientpanda72063 жыл бұрын
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 Жыл бұрын
Code doesn't work, it shows NullReferenceException. Can somebody help me?
@trevornaumann90114 жыл бұрын
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?
@krispyabroad4 жыл бұрын
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
@chaosmastermind2 жыл бұрын
Wouldn't there be the possibility of it spawning infinite rooms since there is nothing stopping it from doing so?
@jrmillerfilms2 жыл бұрын
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 Жыл бұрын
This is great
@advecide6 жыл бұрын
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
@niksprint77765 жыл бұрын
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)
@jacobgallow49604 жыл бұрын
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!!!!!!
@Phamility4 жыл бұрын
Figure it out? Because adding a global room limit variable leads it openings so I also need help :p
@kbenskeer50714 жыл бұрын
i have the same problem, have you fixed it?
@firebubble23 жыл бұрын
It just won't work
@firebubble23 жыл бұрын
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); }
@nickablocka88223 жыл бұрын
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 :(
@Mafi4Wolfy2 жыл бұрын
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_skelly39444 жыл бұрын
The first set of rooms keeps spawning off centered and I can't figure out why
@oneway71224 жыл бұрын
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_skelly39444 жыл бұрын
@@oneway7122 I think my new rooms are spawning from their pivot point instead of their center but I dont know how to fix it
@oneway71224 жыл бұрын
@@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_skelly39444 жыл бұрын
@@oneway7122 I realized I hadnt put them in an empty gameobject yet, just did it and it worked! Tysm! :D
@oneway71224 жыл бұрын
@@supa_skelly3944 no problem man
@danteps136 жыл бұрын
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-lx1ug3 жыл бұрын
did you fix it?
@danteps133 жыл бұрын
@@Alessandro-lx1ug I eventually solved it a different way, but thanks for asking
@Alessandro-lx1ug3 жыл бұрын
@@danteps13 could you please tell me how, i have this exact problem
@danteps133 жыл бұрын
@@Alessandro-lx1ug i dont remember, it was over 2 years ago
@Alessandro-lx1ug3 жыл бұрын
@@danteps13 yeah thats logique welp thanks anyway
@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
@jayshah60565 жыл бұрын
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 =(
@craigsimons78826 күн бұрын
My rooms aren’t spawning
@ArcadeShow2 жыл бұрын
Followed every single step, exactly and just keep encountering error after error.
@sethhoule3705 Жыл бұрын
Little Late but you need to write it as int rand = Randomd.Range(your code):