Unity Tutorial: ROGUELIKE Room / Dungeon Generation (Like the Binding of Isaac)
Tutorial on how to make roguelike rooms and doors generation in Unity, like it's done in the binding of isaac.
Scripts coming soon.
Join the discord server: / discord
0:00 Setup Unity Scene
4:42 Coding "Room" script
6:14 Coding "RoomManager" script
20:15 Make rooms spawn randomly
21:49 Adjacent Rooms logic
25:00 Open Doors
35:06 Outro
Пікірлер: 45
Hey! Great tutorial! Just want to post my solutions for the two problems i can see in your system. 1) The room overlapping Put this check in the TryGenerateRoomFunction : if (_roomGrid[x, y] != 0) return false; 2)The error when a room tries to be created outside of the grid Put this check also in the TryGenerateRoom function (put it before all the other checks by the way) : if (x >= gridSizeX || y >= gridSizeY || x return false; Hope this helps anyone!
@rootbindev
3 ай бұрын
Thank you
@ke77i
Ай бұрын
when you fix the overlapping the first room never spawns with any doors
Great tutorial! One of the better, well explained ones I have seen on this topic. Would love to see more on this series for sure!
@rootbindev
5 ай бұрын
Thank you very much!
AHHH Root how did I miss this upload of yours. I have always had notifs on D: Nonetheless, very organized tutorial!!
@rootbindev
5 ай бұрын
Thank you Panini! :D
Great video, please continue! Adding a few timestamps/chapters to videos as long as this one could be nice, just a thought. But good job, mate!
Everything works just fine! Great tutorial! I'd like to see you explain how to spawn a boss room, a shop, secret rooms, like in Isaac!
@rootbindev
5 ай бұрын
I'm glad you liked it! I might do that in the future!
@picatsso6721
5 ай бұрын
Oh, by the way, I just did it myself, with help of ChatGPT, now it's perfect: Boss Room is always has a connection to only one room and is always the furthest room from the start, also Treasure room and Shop room generating with only one room adjacent to them. It is still based on your code, just saying, if you are interested to see how AI implemented this - let me know.@@rootbindev
Hey, awesome tutorial! I'm currently making a game for my school's game jam, and this helped soooo much. Thank you!
@rootbindev
2 ай бұрын
Thank you, and Good luck with the game jam!
LOVE THIS tutorial! Very thorough and to-the-point!
@rootbindev
7 ай бұрын
thank you!
This tutorial is great, well done and keep it up! I did notice that some of the rooms do overlap on top of each other during runtime. Do you know why?
@rootbindev
6 ай бұрын
Did you follow the tutorial 100%? In my game, using this code I get no overlaps
@ItsReece2
6 ай бұрын
Yes, I did follow it but might be possible I missed something in the tutorial. I must say it's very uncommon it happens the overlap; normally overlaps from starting room and occasionally another room from the neighbouring nodes. @@rootbindev
@FennrirWolf
5 ай бұрын
I also noticed this same issue. It is pretty far and few between, and also as Reece mentioned it is usually an overlap on top of the starting room. Rarer occasions do include non-starting rooms overlapping too. I'm not sure if this is the most efficient fix, but in our Update when we call the TryGenerateRoom 4 time, I added checks for neighbors prior to actually generating in any direction. I have not seen any overlap since I added these checks. if (gridX > 0 && roomGrid[gridX - 1, gridY] == 0) { //No neighbor to the left TryGenerateRoom(new Vector2Int(gridX - 1, gridY)); } if (gridX { //No neighbor to the right TryGenerateRoom(new Vector2Int(gridX + 1, gridY)); } if (gridY > 0 && roomGrid[gridX, gridY - 1] == 0) { //No neighbor below TryGenerateRoom(new Vector2Int(gridX, gridY - 1)); } if (gridY { //No neighbor above TryGenerateRoom(new Vector2Int(gridX, gridY + 1)); } @@rootbindev
@bsdrago
4 ай бұрын
@@rootbindev I have the same problem, and you can see the problem in your video too (eg, 20:07). You can see 17 room created, but only "12" visible
@rootbindev
4 ай бұрын
Try adding the checks that @FennrirWolf posted above@@bsdrago
thank you!
I assume you forgot or didn't want to add the scripts in the description :(
Nice
Sometimes rooms are generating inside of existing rooms, any idea how to fix this?
@rootbindev
3 ай бұрын
I've noticed as some guys told me below, I'm not sure why
Would this also work with tilemap based rooms?
@AvoDev
3 ай бұрын
yeah, I was able to do it with minimal effort, just create a tilemap grid on the room object, and give it some colliders.
ummm some dungeon patterns are repeating like
Great tutorial, how would I go about instantiating something at the last room generated... Edit: Figured it out. Add this code where you set generationComplete = true. GameObject lastRoom = roomObjects.Last(); Instantiate(boss, lastRoom.transform.position, Quaternion.identity); Make sure your script is using System.Linq;
@rootbindev
2 ай бұрын
Thank you for sharing!
Does this work with tiles?
@rootbindev
4 ай бұрын
I haven't tried it but it should work
@Arcann_bhp
4 ай бұрын
@@rootbindevalso how can you edit the room like as content, if there’s only one prefab how can you make different type of rooms
@rootbindev
4 ай бұрын
Make another room prefab that suits your needs, and before instantiating the room you decide which prefab to Instantiate :) @@Arcann_bhp
@Arcann_bhp
4 ай бұрын
@@rootbindev so I can just make a list of room and then randomize with the length of the rooms?
@rootbindev
4 ай бұрын
Exactly! Atleast that's how I would do @@Arcann_bhp
where are the scripts
@rootbindev
5 ай бұрын
I can send them at discord