Binding of Isaac Procedural Dungeon Generation Part 1 - Unity 2019 Beginner Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] I just like to thank everybody for that patience in waiting for the next part of this tutorial series the next few parts are going to go over a basic dungeon generation replicated from binding of issac now this is not the easiest topic for beginners but hopefully I can give you some tips on how to wrap your head around procedural generation so the first thing I'm actually gonna do is I'm gonna create a new folder inside of my scripts folder and this is just gonna store all of my dungeon generation card ok and we want to create quite a few scripts and I'll go through them all at a later stage but for now I'm just gonna create them so we're gonna need a room controller to control our rooms so we're also going to need a room ok and this is gonna be the individual room we also need a door for every door that is connected to the rooms so we can get to our next room we also need our dungeon generator ok as well as a dungeon generation data and this is gonna be a scriptable object which is pretty cool we'll go through that later so hopefully you understand it we're also gonna have a a dungeon crawler controller okay and finally a dungeon crawler okay so let me explain a bit of what we're gonna go through so in this part we're only gonna look at our room controller and maybe the start of our room in a binding of issac style dungeon there are going to be rooms so this is a room okay I have a room over here might have a room over here might have one up here okay now these are all going to be connected via doors okay so if there is a door we want to be able to go through it okay and we're gonna go back and forth just like that and we also want to be able to generate the rooms themselves in a random sort of pattern so it looks pretty cool but not completely random we want to put some rules on it like for instance we want to have a like a start room okay and eventually if we keep going on we might get to our like OOP you might get to our boss room right it's very bad school okay so I guess to implement this we're firstly going to define each individual type of room okay so we're gonna have a start type of room we're gonna have an empty room and we're gonna have a boss room now we're gonna put these in separate scenes so we can load them additively and this will allow us to not like completely freeze the game until all everything's loaded it's gonna load them all sort of one by one and it sort of looks nice when you're loading them up okay alrighty so I've just opened up the room controller script the first thing we're going to want to do is we want to be using our Unity engine dot scene management because we want to make use of all of the cool scene loading features that comes with in unity now before we start within our class I'm going to create another class okay and this is gonna be our room info okay so this is going to have a public string and that's gonna be the name okay then I have a public integer and it's gonna be our x value and if another public integer it's gonna be our Y value so these are gonna be within relation to our scene so if we have a star this is gonna preferably be at 0 and 0 but if we go to the right we're gonna want to have 1 and 0 negative 1 and 0 0 1 and 0 negative 1 okay so we sort of want to keep track of everything within these sort of parameters so it's like our own coordinate system you could say the first thing I'm going to I'm gonna create an instance of this sir this is gonna be a singleton as we've talked about before and keep that gonna call it instance okay now we also want a string and this is going to be our current world name okay so for instance in binding of issac we have your first set of rooms and then once you've defeated the boss you go to the next floor down you could say so we can basically we can call this basement okay and I'm also going to have a room in fur and this is gonna be our current load room daata okay and the next two things I'm gonna make use of is a Q and a list I call it load room Q and we're gonna be able to make use of that so when we're loading up our scenes we want to make sure that we're loading up the first one that's been put in first okay all right cool and also just need a public list of our room okay now it's gonna be loaded rooms okay something equal to in here list of room I hope I also want a couple it's gonna be is loading room and you order flops will make use of that later on to now in our awake method as we've done before we're gonna say instance to this okay and yeah so I think the first thing we want to do is we want to check if a room exists okay so to do that we can just use a bull variable okay and I'm gonna call it does room oops does room exist and it's gonna take in an x and a y value okay now we're going to return loaded of rooms dot find and we're going to make use of what's called a lambda expression in here so we're gonna grab the item and the item dot x value is going to be equal to X and the item dot Y value is going to be equal to Y and check whether that is not equal to null okay and then it'll return true or false appropriately okay so we don't have a definition for our X and our Y in our room so we're going to want to go in and open up out room okay so the first thing that we want to do in here is we want a public int width and a public int height as well as a public int X and a public int Y okay so that'll make our and control a happy from now now I guess the first thing we want to do is we want to make sure that our room is that we're starting within the right scene okay so if our room controller instance is equal to null then we've obviously press play in the wrong scene so we just want to return and maybe you could give like a debug dialogue as well sorry this could be a like I don't know play wrong scene all right cool so the next thing that I want to do is [Music] I'm going to create a public vector3 okay and this is gonna be called get room center okay now we're going to return a new vector3 and this is gonna be our X x our width and our Y x our height okay now as well as this I'm gonna make use of the editor gizmos so we can just have a look at and I guess we're gonna make use of the gizmos so we can have a look in the editor and line up our rooms pretty much perfectly just so it's a bit nice okay so we're gonna set our color about gizmo to red and gizmos dud I'm going to draw a Y a cube so this is a rectangular transformed up position and a new vector3 with out width and height at 0 cool now this should automatically draw that gizmo for our room so if we go back in here now and we go to our scenes I'm gonna create a folder and this would be I guess dungeon rooms okay okay so I want to duplicate it and then I just want to call it basement main okay perfect so we've got this in nicely and I guess now I want to I want to create a starting room so basement start and within here don't want the enemies don't want this enemy don't want the item screw Persian keep the player health and text don't need that don't need that cool so I guess now we want to create our room so I'm just gonna create a game object set it to zero and I'm gonna call this room now within this I'm going to create I guess some walls so cool this left wall I'm able just call it side wall okay and I'm going to need to import some new civil rights so [Music] all right so just imported a couple of sprites text you type sprite 2d ok now I can assign the side wall yeah cool so I'm just drag it over bit small so we can actually extend it out just a bit just like that and okay so yep I'm actually gonna duplicate that and I guess I'll rotate it 180 degrees so it's a bit of the opposite way I'm just gonna place it here and rotate it 90 [Music] finally negative 90 and strike up here sweet so I guess this is like a basic room we can change the guess give it a nice of feel cool nice so we have our basic room I guess so I can drag it in here and I'm gonna add our room onto it okay and I think the other thing we want is the doors so again I'm just gonna create an empty game object hold the door and drag a drag oh hold on to it okay so we can just change the [Music] make it a lot smaller and a comparative here probably want to keep just like that Oh make sure it's over a bit so we want to add a Collider to it at a later date all right so duplicate that okay so we've got our basic room set up now just like this okay now you know basement start we don't actually want to keep our canvas and everything so this is all gonna be within our main dungeon scene okay so we can delete this delete the player donate the event system don't need the game controller don't need the light and we don't even need the camera okay so we've got our start room and I'll just duplicate this and I'll I will rename it to basement and okay and I guess the difference with this one for now is I can just add in a sprite okay okay so we've got our little start and I'll just go over to our start and I will add our sprite into our room okay cool so I think I'm just gonna end this one off here and we'll continue off in the next video and get into some hard cutting so I guess this was just a general set up and we'll go through and set up colliders next and we'll also go and start working on implementing our scenes into our main scene so we can spawn our rooms so yeah I hope you guys enjoyed the video if you did leave your thumbs up and leave a comment for any feedback that you may have or some features maybe that you'd like to add into or you'd like to see put into this game thanks I'll see you guys next time [Music]
Info
Channel: JVCOB
Views: 42,984
Rating: undefined out of 5
Keywords: Unity, 2019, Tutorial, Beginner, Binding of Isaac, Procedural, Dungeon, Generation, Chillehh
Id: YJ97rvHiNzQ
Channel Id: undefined
Length: 19min 22sec (1162 seconds)
Published: Fri Jun 07 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.