How To Create Epic Procedural Dungeons In Unreal Engine 5 - Part 2

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys welcome to my video and my YouTube channel my name is Ronnie and I made this procedural dungeon tutorial part one uh some weeks ago and you guys completely blew me away with the amount of of interest in this dungeon tutorial I got a lot of views on this video and I got a ton of positive comments saying that people uh loved part one and it it was completely mind-blowing to me I was not expecting any want to watch that video at all I mean how many people in the world need a random generated dungeon I don't know apparently a lot of people have been looking for a tutorial like this including myself so guys I'm Blown Away by your support on this video and this channel so naturally I want to move on and make a second part for this tutorial in this video we are going to expand this procedur dungeon I'm going to show you how to make a seed system for the dungeon so you can get a completely random dungeon but you can also type in a seat number and get the exact same dungeon every time you press play it will be an option that you can easily select I will also show you how to create like second floor of the dungeon like you know basement first floor second floor and so on I will also show you how you can spawn different things in the dungeon in this case how to spawn gold coins and how to spawn treasure chest and this could be anything that you would like it to spawn like enemies traps player character anything you like so guys sit back grab a cup of coffee and some popcorn and let's [Music] begin all right guys let's take a look at what we created the last time in part one we ended up with a pretty awesome looking dungeon right and these hallways are really splitting up the dungeon in a in a in a great way right and I hope you guys have made some more interesting rooms than I have right here so um it's all a matter of the rooms right the more awesome and different rooms you have the more awesome this dungeon will become so the first thing I want to do here is to set up a system for the seed so you will be able to type in a specific seed for the dungeon and that will be the same dungeon it loads every time as long as you're using that specific seat and I will also make sure that we Implement a system so you can also get a completely random dungeon every time right so you have both options completely random dungeon or a specific set dungeon every time okay so just just before we do that I just want to show you guys that you can you can right click on a folder and you can set a color for the F folder right so you can get some badass looking folders right and you can easily find it and you can also can you drag it into the favorites no you can right click and add to favorites because we'll be using this folder all the time and as the project scales up it's very nice that you can find your most important folders all the time so let's get back into our dungeon generator here and let's see what we need to do we you need to just find some space here let's make a custom event you should know what a custom event is by now and we will call it seed set seed maybe and we need a integer so go to the variables make a new integer call it seed and make it an integer compile it and grab it drag it out get seed this is our seed this is the so you type in 555 and every time a dungeon spawns and the seed is 555 it will be the same dungeon every time change the seed to something else 55555 I don't know it will be a different dungeon but it will be the same every time this number is the same right then we will make something awesome so if we put in minus one it will always be a random dungeon so let's let's just try and make that to begin with here so drag out from the custom event type in Branch we will make a branch so we say if this seat is equal type in equal if it's equal minus one plug it in to the branch so if it's minus one we go on the true and we will create a completed random dungeon every time if it's not minus one right here it will be a specific number every time so click on the seat now it's minus one it will make a random dungeon if we type in something else it will go to false because it's not minus one and then it will create this exact dungeon every time and now comes the tricky part which I'm will probably not be able to explain because I don't understand how it works we need something called a stream so if it's minus one if you want the random dungeon we go out from true and we will type in random stream and we will select the one called seed random stream this means that this stream will be random and it's the stream that kind of it I mean it's the stream that kind of detex uh the number of the dungeon the dungeon ID right is the exact same thing as the seed but this is an integer and this is a stream and I don't know what a stream is uh but this is what we're going to use everywhere we doing something random we won't you know let's see here random integer every time we use something like this we don't want to use it we want to use the stream okay this is already confusing for me let's just move on and I will explain it down the road so we right click on the stream and say promote to variable just to make sure we're getting the correct variable to plug in here and we will just call it stream because that is what it is so guys if if the number is not minus one we want to go out here and we want to set the random stream seat so set random H what maybe we need to copy this one copy this stream and set random stream seed I don't know why it didn't work before set random okay I probably just spilled it wrong all right anyways if it's false if it's not minus one if it's anything else we will go down here and we will plug in the seed so copy this seed paste it in here plug it in here that means that this stream will get this seed number over here if it's true if it's minus one it won't get the seed number it will just make a random number for the stream does that make sense the stream is not getting any information from the seat but down here the seat is you know uh paste all the information to the Stream So the stream gets the same number as the seed does that make any sense and guys this is nuts this is basically everything you need to do to control if you're getting a random dungeon or if you're getting a specific dungeon but of course right now it's not doing anything but but let's just uh make a comment here and say set C he if minus one then it's random right we don't color it green now because we don't know if it works so where do we do this I think we need to do that in the very beginning before we start creating anything we need to get the seed so drag it in here from the event graph set seed this is the uh custom event we made and now we're playing that as the first thing when this dungeon uh plays but again nothing will happen because we need to put in that uh stream everywhere we're using something random so let's go down here what do we have spawn start room that will be the same we don't need to do anything there here we have a random and to make this work we need to get rid of this uh random node right so we drag out from exit list type in stream yeah there's not a lot of options random array item from stream grab that one then get your stream over here to the left drag in the Stream get it and plug it in here so now instead of getting a random room from the list it's getting the room uh from the stream and this stream you know it has this number this just say 111 that is the seed uh number we created in the beginning that means that is also the number which will be in this stream I mean it doesn't mean that it's getting exit uh exit number 111 that's not what it it means it's just a number holy guys this is all already super complex to talk about and to explain I mean it's it's it's just a a the stream number just determines how everything is laid out in the dungeon which means it will spawn the same rooms it will use the same exit it will make it will use the same spawn points when we get to that later on everything will be the same I I just proved that I cannot explain how this dream works I think it's just a number uh a reference number that it uses for everything I don't think I can explain it any better I'm pretty sure if you know how to explain this better please write it in the comments I would love to read it the thing is now we take this random from stream and plug it in to the selected exit point and then we delete this random delete it make it pretty so now every time next room is created it will use the same exit Point uh because of the stream number if I change the number it will change the exit points that is getting selected but this is only the exit points we need to do the same for the rooms which is this one the room list which rooms are we selecting every time we get an exit point and we need to choose a room which room is selected right now it's just completely random we don't want that so drag out from the room list type in stream random array from stream get the stream down here in the variable list plug it in to the random stream and then plug the out item into the class remove this random because it's not really random anymore it's determined by the stream which we select by typing in what seed we want in our seed integer that is getting passed on to the stream let's just go through do we have any more random stuff going on I don't think so no more random close holes all right guys let's see if it works right now the seed is set to 111 let's press play right now we have 30 rooms to test out whoa it didn't have enough time you see it makes the same this is a good example the I think right now the timer is running out right so we don't have time to finish the dungeon but you can see it's the same dungeon every time which means it it it works let's just uh I mean let's let's give it some more time where did we do that uh Max dungeon time I mean again it's been a while since I worked on this tutorial 15 seconds let's see if it works same dungeon so something is working dungeon complete there we have it let's change the seed number down here 2 2 2 two 22 two it's a lot of twos compile it doesn't really matter what the number is could be 10,000 Millions uh or it could be one doesn't really matter remember this dungeon let's try again it makes the same dungeon right I think it's the same one yeah it's doing the exact same thing every time see this is pretty cool so let's try and put it to minus one let's go down to the seat type in minus one right remember what happens when we put into minus one if the seed is minus one if that is true we just select a random stream number or whatever yeah I think it's just a number so instead of it getting the number from the seed it just gets a random one if it's minus one I'm hoping this is working too let's see let's get some more space here that's a very odd look dungeon see this is a different so it's it's it's random every time so what we can do we can go down to the seat the integer we can uh over here to the right instance editable Expose and spawn if we're going to spawn the dungeon in some other way we want to expose it that just means when we select our dungeon generator here in the level uh outliner then we have the seat down here the default is minus one we can set it to something else and it will be the same every time same dungeon and it will take the exact same amount of time because it's doing the exact same thing every time it's still spawning overlapping rooms it's the same overlapping rooms every time so it will take the same amount of time set it back to minus one and we will get a a random oh set it back to minus one down here we will get a completely random dungeon I think you're getting the point now this is just super important also for troubleshooting right you can find a dungeon that doesn't work maybe it just ends up using all the wrong exits every time then you can set it uh you can get that seat number and you can try by spawning the same dungeon all the time you can try and solve the the lag of exits uh you know it's good for troubleshooting because you can get dungeons that doesn't work and you can try and fix them so guys I hope that makes sense now we can make this one green because it works we can we can put it in anywhere where we think it looks good so seed is very important I think maybe for troubleshooting we can uh go back in here and we can make a print string so so no matter if it's true or false it will go to print string and let's copy the stream paste it in here again if you copy from here doesn't matter if we can also take it from down here get it it's the same thing we can plug it in of course that doesn't work I don't know why that doesn't work can we convert it to I don't know text string integer no anyways I don't know how that works but the idea is that we can get it to print the stream number so if we see if it's just a random dungeon we're working with we can get it if we run into a problem or if it's a specific dungeon we really like we can read the Stream ID from the print string and we can write it down and we can use that stream if we like that but I don't know how it works so just delete this again again let me know in the comments if you know how to print a stream I don't all right let's move on guys so guys the next thing uh many of you have been asking about is how do I make different levels in the dungeon you know like BAS ments first floor second floor uh how do I create the dungeon in different levels and I mean I haven't tried it but in my theory you should just change you should just make a room with a stair in it and move the exit points up we don't need to do anything in the dungeon blueprint so let's just take a room here uh how how are these rooms don't we have a room with three exits dungeon room one is this the start room did we make a start room guys I can't remember no anyways we can take let's just take this dungeon dungeon room to duplicate we call it dungeon stair stair room stair room one like this let's open it up let's see what we have I mean in theory we could just move everything up here uh so select the floor select the walls like this can we just duplicate it control contr Ctrl V yes it ends up in the correct folder we can move it up I don't know how how how I don't know how high we want this to be but let's just let's just make a room here like this all right and then we need we need to close this one copy this now I'm just making room now I mean you can make your rooms however you want right and then we need uh is there so copy this move it down here here scale it we also need to close this just close it like this I'm not going to spend time uh this time on on trying to line things up because I I can't do it anyways um so is this ever going to be some kind of there it's a little crazy but uh doesn't matter I'm just copy pasting this box so something like this oh did I'm just copy pasting these blocks around copy paste rotate move it in here move it over here and I mean yeah yeah again I'm not going to spend a ton of time on this so now we have a stair room of course you need to make walls close these walls doesn't matter we need to be able to see what we're doing right now if it's working at all or if we're just wasting our time so move this Arrow up to make it sit perfectly with the floor otherwise we'll get a a small Gap and I mean guys this should work in theory let's try it so we need to go into the dungeon generator here go to the room list and we need to add a new room let's make two of these just to see so we get a bigger bigger chance of spawning it and select the stair dungeon stair room we just delete this one and then duplicate it so now we have two stair rooms in the dungeon dungeon generator it's still minus one so it's random let's try and see what's happening oh another thing we forgot we forgot to change the overlap [Music] box right we need the overlap box to have the same uh Dimensions what's happening here so 64 I can't see okay it's down here can I just reset this to 32 and then make use the scale instead 32 scale ah 40 30 I don't know 60 I don't know guys 20 it just needs to be kind of inside uh wireframe wireframe so you can see the boxes go go way down below uh the ground which is bad so I think we should we should fix that so scale it again I mean we need to keep the rooms inside you know in in inside this uh you know area of the rooms inside the overlap box all right I'm sorry guys it's a little clunky but uh I mean you will spend more time on your dungeon rooms to make them awesome so now the room is already in there this try and see what's going on so now we have two stair rooms and it goes up and then dungeon is continuing above and we have more stair stair rooms over here you see of course you need to make a star down room and we have some problems here you can see the arrow and the floor is not really lining up why isn't why is that the case because this Arrow needs to go down here right let's just open another room see how it works uh okay so it's just all right so maybe the problem right here is that the the room floor is higher up than the arrow the arrow is in zero so the arrow is what where it's supposed to be but the room is too high right so if you take all rooms and move them down to the floor so so the floor level kind of uh is at the same level as the arrow then it should work front you see the floor is not in zero it's over here let's just do it right let's just let's just see if we can move do it correctly move it down to zero that's zero and the arrow is zero that was one room that was room two room one select all the walls and Floors go to the front view move it down to zero should be zero here room three get into the front view move the floor down to zero all right room four go to the front select all the walls and the floor move it down to the arrow Dum room five I mean I could speed this process up but um front Jesus Christ front wall move it down like this this is the arrow it's in zero which room is this ah it's the yeah and then we have the stair stair room where we of course also need all these walls and the floors on the top to match with the arrow like this go into front so now you just need to know where the floor level is and that is this line so we need to move that down like this to the arrow and then we of course need to make this stair piece a little lower yeah something like this it's a stair room that is what it is it's easy to see let's go in did we do it on the are we missing any rooms no let's see if it works now see guys stair room and the next room is aligning perfectly so of course the end walls needs to be moved down too so now we have a dungeon in different layers and of course we need some kind of way to control you know how many stairs ups and downs are we going to use we also need to make some stairs that goes down so you can get down from here again but again guys this is this is not too bad right I wasn't actually I haven't been thinking about doing something like this uh that's next level but I mean it's just making a new room move the exit points up or down to where the stairs are ending and it will create rooms from that it creates room from wherever the exit arrows are so we don't even need to go into the dungeon generator to create specific level code or anything like like that I mean it just works and just it just works but and remember to set your overlap box to the same size as the room also in this C axis in the height so we don't get any overlaps let's try and make another one see how it turns [Music] out and I think the problem we have right here is why is that a problem that is because I think maybe it's because this stair room uh has some problems in in some way yeah that's because the floor again the floor of the stair room is also not uh at zero right you can see this icon here that is zero and and the the room anyway let's just do it as we did before select all the walls remember to select the overlap box which is a little too big now I can see and select the arrow did was the arrow selected yes go into front move it down to the correct level here make sure the allet box is not too big 25 maybe 30 28 whatever just make sure it's it's still inside the room but still the same size as the room just a little smaller than the room so again should work yeah see now the stair rooms are also lining up I mean the problem here is is my modeling uh the stair model is not too good CU see now we just get a dungeon that just goes up and it's not very useful to be honest so and that's why we need some kind of system that let's say we can only use two upstairs and two downstairs when those are used we will remove those rooms uh from the room list something like that okay guys let's try and see if we can do exactly that okay let's let's try something we will copy the room list okay so what I'm trying to do right now is to make a room list with special rooms in it like a stairs or throne room or Clock Tower or whatever something way we can only have one off for example and so every time the dungeon has put down like let's say 10 rooms then it will change the room list to the special room put down room number 11 as a special room and when that is done go back to the regular room list again does that make sense so we get one special room in the dungeon and this could of course change so we could do it every fifth room for example and then we'll fill the special room list with special rooms and we'll make sure to remove if a let's let's say it puts down the clock tower room when that is done we will remove that from the special room list so it can not select the clock tower again okay so we can only get one Clock Tower in the level in this case it will be a staircase let's see if we can make that happen so first of all we need to remove the two stair rooms again from the room list so delete those two delete then we need to copy the room list duplicate call it special room list for now can we move it up here we can so we have room list we have special room list compile it then add I don't know why I added all these remove this add one select the stair room all right so now it has one thing in the it has the stair room in the special room list all right so let's see where we are here we are going down to the delete latest room if overlapping this is where the successful room if this is false means that we are getting a room placed down and we go down this line then if there's more room left we will spawn the next room if there's no more rooms left in our room amount we will Capt the holes and and everything yeah let's fix the holes later on so what we want to do here if there's more rooms left if the room amount let's get out the room amount here copy paste it out if this is let's say equal 10 like every the room number 10 or 11 I can't really again the math here is just when we have 10 rooms the next room will be a special room right so hold down B and left click to get a branch plug it in here line it up uh make everything small so if the room amount is equal 10 we want to uh set the room list drag it out and we want to set it we want to set the room list to the special room list so drag out the special room list get it and plug it in so now the room list has been turned into the special room list I think so if it's equal 10 we will use the special room list instead and we will spawn the next room if it's not 10 I think we need okay so get the room list again set it we need H see this is the problem we need to set it back to the room list and away from the special list and we cannot do it like this because the room list right now is the special room list right so room number 12 will still be a special room because we changed the room list to the special room and we need to fix this so we need to S we we actually need three room lists right we need a room list called base room list SP room list and one called room list which is the one we have right here this is a little messy guys I I hope you you you see what I'm talking about here so let's copy the room list again duplicate let's call this base room list compile it and it has all the basic rooms remove this one so we need to take the room list so you now so right now we're changing things around you need to look at the room list here set it the room list as the the list that the the rooms are getting selected from and we can change this list to special room list or base room list let's just move it up so we have room list and this room list is what we will change all the time that is where we take the rooms from and it will be set to either the base room list or the special room list depending on how many rooms we have already placed that okay it doesn't it might it might not make a lot of sense right now and I'm also bad at explaining this but let's just try it and if it works I will try it and explain why it works so if the if we have set 10 rooms down we will change the room list to special room list and we will place a new room which will be a special room so the next room where this will be 11 which means it's not 10 if it's not 10 we go down here and we will change this room list to the base room list the original room list again and then copy this copy paste and we will spawn the next room you can also just plug it up here but I think this look messy so uh we just do it like this so we have our lines anyways guys let's I mean this should in theory be exactly uh what we need to make this work so base room list is all the dungeon rooms spatial room list is the stair we are not removing anything right now let's see so in theory right now we should get one stair room we have it over here but yeah okay it will be one of the last you can see okay over here let's select the dungeon generator you can see room amount we start off with 30 that is why the stair room came so late in the process because we need to place down 20 rooms first before we can the room amount is down to 10 and it will place the staircase let's press you see how the room numbers go down when it reaches 10 it sets the stair room which is not really leading anywhere but uh that I mean let's try again yeah here it leads somewhere else so I think what we can try and do here is we can say also on the 20 so if it's equal 10 let's try equal again put in equal here let's make some room so if it's equal 10 or if it's equal 20 then now we need an or I think or or Boolean so it's if it's 10 or if it's 20 if any one of these is true it will it will it will uh use the special room list instead of the base room list so now we should get two stair cases if I'm not mistaken that was one that was two so I mean it look like it works yeah we're getting two staircases now that goes up every time but that's how we made the room and again the staircases will just be uh put down randomly every 10th and every 20th room and it works and this could be again it could be a throne room it could be a clock tower it could be a I don't know anything you want it to be that a room that you can only have a a few of in your level maybe only one so you can see now it it's getting a little more complicated so I'm not sure if that makes any sense at all it it's it might be a messy solution this thing here and all this and there might be better ways of doing it but I don't know any better ways of doing it and and it kind of keeps it simple to understand what's going on here to me it does at least but this is a fairly easy and simple way of just changing the room list to contain a special room at certain points in the generation and then when that room has been placed it switches back to the base rooms again uh best case we need a way to let's say places down the clock tower we need a way to remove that clock tower from the special room list if it's the clock tower that get selected so it doesn't get selected again right now I don't have a good Solution on how to do that so so I will just leave that for now maybe we can put that into part three if we are getting that far we'll see about that so yeah this is a kind of a a quick and dirty way of doing it getting two special rooms in I mean it kind of works right and we got the staircase room to work also uh and we had limit uh the amount of staircase rooms that is getting put into the dungeon by by doing it this way and I think that must be good enough for now let's see if we can improve this in the future maybe no one knows okay we will leave this as it is right now um and now I want to go in and make spawn points so you can spawn whatever you want randomly in these dungeon rooms so let's just close all these rooms for now here and then we need to go into uh what did we call it Master room so we go into to the master room and then we make a new folder a scene and we call it uh floor spawn points or locations or whatever you want to call it uh and then we compile it and this will be things will be spawning on the floor like enemies coins trasure chest uh the player things like that then later on you can make wall spawn points ceiling spawn points and so on or you can just keep everything in in under one called spawn points doesn't really matter but floor spawn points then we know what it is uh it is things we are going to spawn on the floor so in here under floor spawn points we will create an arrow again Arrow we call it spawn point I mean it could be a cube it could be anything it's just a location let's put up the size on this arrow and we will rotated uh 90° no that's not the rotation oops sorry rotation 90° like that so it points up we will not be using the rotation or the scale only the location we call it spawn spawn point one like this cuz the next one will be called two can we get a space in between here two so one okay so place it where you want things to spawn copy paste move it around we'll just make some random ones here something like this I mean you can you can do whatever you want in my uh my new game I will these are everywhere so everything can spawn anywhere so something like this these are the spawn points compile that is dungeon room one so we select spawn point one control C to copy it go to dungeon Room 2 floor spawn point paste it I don't know why they're not getting paste in here anyways but they need to be under this folder other otherwise this system doesn't work then just you know copy these around again something like this compile we can just select them all copy go to dungeon room three floor spawn points I mean we did this in the in the in part one also for the exit points right looks fine place them where you want doesn't matter too much copy dungeon room four paste it move it to floor spawn points beautiful compile dungeon room five that is the hallway paste it all right so we don't we can just need to move these back into the hallway here and remember to place these inside of the folder I'm forgetting to do that in this clip and of course place these where it makes sense in your game right make sure they're standing exactly on the on the floor cuz that is where treasure chest and and other things will spawn from so they don't intersect with the floor so go to room stair room we also need stuff in here what just happened I don't know uh spawn points pasted see these are stretched right or what why are they stretched anyways put them in the uh floor spawn points why are they stretched are they anyways that doesn't really matter but it's a bit weird anyways this is not scaled so default everything so maybe they're not stretched anyway it's just me so take some some of these uh move why can't I select them what what is going on here I can't select them okay delete those I'm not sure what is happening dungeon room one copy all the spawn points paste them why it's all what is is it my viewport here that is so now it's not anymore I don't know guys what that was about paste it in so now they look right for some reason move them up make sure they are exactly on the floor so select the points move them up the ones that are inside the staircase move it like this I mean that is fine there's one inside staircase just get it up again maybe you can just skip to the next uh chapter in the video I will make sure to make chapters this time so we can skip things like this or you can keep watching to I don't I mean I don't mind move it all right so that was the last room now all the rooms remember to save all the rooms have spawn points now so now we need to get into the dungeon generator and we need to add all those points to a list as we have done before so make a new custom event call it at floor spawn points to list and then we need to get the latest room the room that has been spawned we need to get the floor spawn points yes it's down here get the floor spawn points it already knows it's the master room that this room comes from drag out get children we have done this in part one too get children components so we need to get all the children inside this folder and we need to append it aend array and we need to move it to the bottom oops almost crashed move it to the bottom so we right click on the empty here promote to variable then we have an array which is a list we call this array for floor spawn list and we plug it in like this and that is what we need to do to add all the spawn points to a list press C call this at floor spawn Jesus man points to list I usually just call these uh comments the same as the event it is uh in encapsulating right so now we have that event where do we play this event when does this happen let's see when does the exit Point stuff happen so let's go down probably with the overlapping uh here so we could I think we can just plug it in here so yeah I think we need to move all this forward make some room [Music] and then I think we can plug it in here when the room is successful so go into the event graph over here add floor spawn points to list custom event drag it in plug it in here and there we go so far so good compile okay so now we need to make the event that selects a random spawn points and spawns an actor which could be a coin or a trap or anything like that so let's go down here let's make a custom event and call it spawn H let's just say coin at location spawn coin add location so first of all we need to uh let the dungeon know how many coins we are planning to uh spawn so we make a new variable here let's call it coin amount we will make it into an integer we will over to the right click on instance editable expose on spawn so we can control it from from outside this blueprint compile it then let's just say how many coins do we want 30 coins 50 coins right drag it out get coin amount so if the coin amount is less or equal to zero that means we have no more coins left to place Press B and left click to make a branch so this is the and plug it in here this is the first thing we need to check do we have enough coins to even spawn one we can spawn any coins if they're all used up which means that if the coin amount is is uh uh lower or equal to zero less or equal to zero then it's true and then we don't do anything we don't spawn anything if it's not list or equal to zero that means we have more coins in the pocket then we go out from false but we need to select a point first so we need to get this floor spawn list out drag it out get it we need to get the list and we need to select a range random one a random point from the list and this is again where we have to use the Stream So drag out type in random array item from stream normally we use the random array item to just get a random one but we need to get the random one from stream so it's the same every time that stream number is the same and we already have the stream that is down here drag it in in get it and plug it in here so now it's selecting a random point from stream and which will be this one so we need to drag out here and promote this one to variable so so we know so we have the spawn point here this is the selected spawn point so rename this to selected floor spawn location or spawn point whatever it's it's doesn't matter all right so compile it and then we can go and say after the spawn location has been selected we want to spawn actor from class this is where we select the gold coin we need to get the location of this uh where the actor needs to spawn so we can write click on the transform and say split the scale needs to be one the rotation needs to be zero and the location we need to get from the spawn uh location that has been selected so we can drag out uh hang on I need to compile where is the selected floor spawn point selected floor spawn location why is it in here I don't know why anyways I was just expecting it to be in this with with everything else but it's inside components for some reason I don't know why the exit points are two doesn't matter you grab it drag it out get it and then we need to get the location get World location so we want to get where it is in the world and you drag it in to spawn transform location compile it will show you an error because it right now it's not spawning anything and apparently that's an error and remember to go down to Collision and select always spawn ignore Collision so other geometry is not pushing it around so it end UPS in the weird places when when this has spawned we want to remove it from the list the spawn points so other things are not spawning on the same spawn point so get the floor spawn list drag it out get it drag out out say remove uh remove item plug it in here and also get the selected floor spawn location get it and plug it in here so it's removing this location spawn point from the list so now it's no longer in the list and it cannot be selected again for the next coin when that is done we want to subtract one from the coin amount so drag out the coin get it we want to get how many we have left we want to drag out and say subtract subtract one coin from the amount we have and then we need to drag out the coin again and select set it so we want to set the new amount so we're getting the co amount let's say it's 10 or 50 we subtract one then it's 49 then we set the new count coin amount to the result of this which is 49 so now the coin amount is 49 and when that is done we want to drag this all the way back to the the branch we want to check let's just move this so we can double click the new line here move it up move this down place it so it looks awesome set a new Point here double click it move it up so you can see that it's a loop this is a loop it goes all the way back now we check again do we have more coins left if we have go ahead select the new Point spawn the new coin remove the from the the spawn point from the list remove one coin from the amount then check again how many do we have now when it reaches zero we won't do anything so that's it for this thing guys so select everything press C call it spawn coin at location let's keep it gray we don't know if it works now we need to make a coin because we getting we're getting an error here we have no coins in here so again guys I will just keep everything in the procedural dungeon folder for now so where so we know where stuff is this is the blue folder right click blueprint class actor coin pickup and I mean this is just to show you guys how you can spawn random stuff at random uh locations in the dungeon maybe your game don't need any coins doesn't matter then maybe it need something else so let's make a coin we are in the blueprint now add uh is there a cylinder cylinder add a cylinder call it coin maybe call it coin mes that's more appropriate so scale it down like this I don't know how big this coin should be 0.2 0.2 0.02 I don't know drag it up rotate it so it looks like a a coin pickup whoa I have no idea how big this thing is compile it and you can see the center of this blueprint is down here which means that the coin will spawn this point right here will be set to the selected location in the dungeon rooms which means that the coin will be floating and I think we want that right you can go in here and add uh a rotator I think rotating movement it's called we add that we go over here to the right rotation rate let's just try and say um uh simulate yeah it's rotating around the correct axis it's a little offset so go into what left view what this is just taking up all the space I think it's fine looks fine to me so compile this blueprint and go into the dungeon generation plug it in here just press the arrow because the blueprint is already selected out here you can just go in press the arrow and it will put this selection in here compile it and there should be no errors so guys up here we put all the spawn spawn points into the list and we doing that down here so that is active so we need spawn the coins at location we need to do that after the holes I think we can just plug it in here move all this to the side get the spawn coin at location plug it in here so when the holes has been uh capped then we spawn all the gold coins and then the dungeon will be complete let's see if it works this is the this is where everything can go wrong press play 30 room dungeon dungeon complete are we get we're not getting any coins let's search over here coin we're not getting any coins all right let's see what that is about go into the dungeon generation again I am not really sure what is going on let's go and select the dungeon we have the coin amount here let's watch if anything is happening to this amount when the dungeon is complete or right before it completes no so it's not running so let's see what's happening in here double click it not that one uh in the bottom here spawn coin at location so we have 50 coins when it's less or equal zero if that is true it should do nothing so here we have one problem move it down to false you can move these around by holding control and drag it if it's less or equal zero we don't want to spawn anything new if it's not equal that means we have more left then we want to go here so we're getting location but are we now we spawning the coin always spawn we removing this spawn location we removing one coin I mean it should it should work right let's try again we're looking at coin over here coin amount 50 it went down to zero so we have coins they're just super small all right let's just go into the coin make it bigger so we can actually see what is happening turn the lock on 0 five move it up give it something shiny o we have one here can we get more shiny stuff I don't know maybe it's shiny enough compile try again make a dungeon where are we here we are there we go see we have coins guys and again of course you need to go into your coin blueprint make sure that when your character is walking over it or picks it up that it will disappear right you you make your coin work right so stop it let's see if we can play new editor window we have all these arrows remember to set all these arrows to Hidden whoa that took a long time before these spawned why we have them why let's press simulate again so when the dungeon is complete and that is because I don't know we have a we have a delay here 1 second after the dungeon is finished it will cap the holes so we could see the holes just transy it to zero so caps the holes spawn the coins at location completes the dungeon stops the timer and writes dungeon complete so everyone can see it play again there we go guys we have random coins spawning of course just put a ton of spawn points in here and and these coins can spawn anywhere and again if if someone have a better way of spawning things in the dungeon right now I'm setting a spawn location point for every possible spawn location which which is is a little is a little much when you have a lot of rooms and you have all these spawn location there so there must be a better way of doing this but this is the way I'm doing it in my new secret game uh and actually also the way I'm doing it in the adventures of com so um there we have it guys so guys we know this works now we make it green I mean maybe we can just try and set the coin amount to 100 see how that works of course you canot spawn more coins than you have spawn points then it will probably give you an error and saying that this is not available um or maybe it will just spawn in in in World zero location I don't know let's try with 100 where's the dungeon here so now we have a ton of coins so I think that part works you go in here select all the coins see coin pick up 99 and we have one called zero so there's 100 coins right now let's say we want to spawn a treasure chest and this is okay so now we come to the point where people who know blueprint and programming will probably don't like me but this is this is a simple and easy way of doing it right so you you mark this contrl C to copy it go down here control V to paste it we can do this in a smarter way um I might go into that but let's just do it the fast way here so we take the event we call it spawn Treasure Chest at location I mean the location part you can just spawn spawn Treasure Chest would also work right compile so the coin amount we need to copy that duplicate it call it let's call it chest amount I mean you already know how to do this right now right how many chest do we want let's just want five Treasure Chest coins 50 so we are getting um we're getting the floor spawn list from the stream we're getting a location we need to plug in a treasure chest here we need to remove one from treasure chest and not coin so just drag the CH the chest okay words are hard drag the chest amount in on top of the coin amount like this also drag the chest amount on top of the coin amount here where we set it that should be all we need to do now we need to go and make the treasure chest so right click make a new blueprint class make an an actor call it Treasure Chest this go into the treasure chest and then you just have to make a very pretty chest treasure chest in here so Cube we have a huge Cube here like this can you make a can you make a what you call it triangle uh cylinder cone Cube I don't know let's just make another Cube drag it up rotate it 90 40 45 45° scale it down like this 0.7 see guys it's already looking like a treasure chest move it up in World wow this is mind-blowing guys whoa this is apparent for some reason don't know why so there I could figure out how to add it to the selected thing over here anyways can we make it look more like a treasure chest I don't think so all right it's a ra chest guys remember to make sure that it is standing on the floor so select these two things move them down to the floor like this there we have a treasure chest on the floor go to the dungeon generator make sure it's selected down here generator plug it in here and then we need to make sure that this is uh that we're playing this at some point and we need to go up and just do it after the coin move this to the side drag in spawn Treasure Chest at location plug it in here and compile let's see if it spawn five treasure chests see we get the two stairs it's awesome we have coins do we have any chests we have no chests all right why spawn Treasure Chest coin amount all right we need to put chest amount in here chest amount chest amount chest amount trace a chest let's try again dungeon complete we have a treasure chest look at that man we have ooh jackpot room look at these awesome chest man I want just want to go and pick them up right you come in here whoa which one do I pick right all these coins fantastic guys do we have anything above we also have things above on the second floor we even have on the third floor too look at this this is how you spawn random stuff in your dungeon all right let's stop it save all save everything because everything is working I mean I'm hoping it's working for you too it's not just my system here that works so the thing is guys uh I'm doing the same thing twice here and every programmer that is watching this or know anything I mean programmers usually say that if if you are copying and pasting code around then you're doing something wrong this should not be necessary it should be possible to make a custom event or a function that takes care of this one time and then you just you know plug in if it's a chest or a coin you want to spawn like you're getting something like this with some more options where you plug in your actor you plug in the amount uh instead of doing it twice right then you'll just make one event of function that has more options so you can plug stuff into it but I'm not that strong uh in things like that yet I know you can do it but I will be fumbling around for the next 45 minutes to figure out how to do that so this is the kind of the simple and easy way to doing it so you just yeah I mean just copy paste this for if you want to spawn an enemy if you want to spawn uh something else like the player character you can spawn the player character in the same way you just select the player character over here um so this is I mean and you'll be expanding this down with copy paste and that is a bad thing but I mean for what we're doing here I think it's fine uh let's not go into more advanced stuff also because I'm having a hard time figuring it out myself uh and I don't want to confuse you with redoing a lot of stuff we just did just to make it a little cleaner it's uh this should be fairly easy to understand what's going on here right so the last thing we need to do here is we need to go into the end wall because it was kind of floating select it going to right or front just make sure that is sitting on the floor right make sure your flooor is at zero the arrows exit arrows is at zero and the end wall here is at zero also so everything is standing on zero I mean it should uh should work now yeah see all the invols are fine I don't know where they are where are the invol there we go here's an end wall and it's sitting perfectly on the floor as it should so that's it guys that was the second part of this dungeon tutorial I was very surprised that the part one did so well and so many people watched it and was interested in it and also interested in a part two I I mean that really surprised me I wasn't expecting anyone to watch this tutorial I am super happy guys that you're supporting this video and this Channel and you're watching this stuff I'm creating I don't think I'm doing very well at this at all but you you kind of you keep reminding me that it's actually pretty good what I'm doing here so guys I'm super happy that you are here and you're watching my stuff that's just what I want to say here I have been uh thinking about stuff to do for a part three in this tutorial but then we moving into more advanced and confusing stuff and I'm not sure if uh if I can do that I will think about what we can add for part three please give me some suggestions in the comments and I will see if I can do it if it turns out that it is too complicated and too difficult for me to do then part two will be the last part for this tutorial but you know anything can happen no one knows and again guys thank you very much for watching and see you next time [Music]
Info
Channel: REE ANIMATION & GAMING
Views: 4,401
Rating: undefined out of 5
Keywords:
Id: lNwn2yq6qXg
Channel Id: undefined
Length: 90min 38sec (5438 seconds)
Published: Tue Jun 04 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.