How To Create Epic Procedural Dungeons In Unreal Engine 5 - Sottotitoli bilingue

hi guys welcome to my video and my youtube channel my name is Ronnie and
today I will show you exactly how I created this procedurally generated
dungeon that you can use in your game every time you press play you will get
a new random dungeon and it's absolutely fantastic guys I will show you everything
step-by-step I won't cut anything out and I will make sure that you see
everything going into this dungeon I have searched youtube myself for videos on
how to make procedural dungeons and I just couldn't find any good ones so if
you are in the same city
situation as me and you can't find any good tutorials on dungeons this is the
video for you anyway guys enough talk let's get right into it so sit back
grab a cup of coffee and some popcorn and let's begin the tutorial okay guys so here we We are in a completely new project,
the third-person template, and I will just work from there.
To begin with,
I would like to look at something a little prettier to my eyes,
so I will delete everything over here, except for the skylight and the post-process volume.
Delete this.
to him stack,
go into the skylight,
turn off real-time capture,
set a specified cube map and then select something you like,
like this one maybe, yeah this looks better to me, we can turn up the brightness to whatever you like.
let's just keep it like this for now you can play around with the light color
if you want something a little warmer like this all right then I will need to
delete all these things in here except for the player start and the lighting stuff.
Just delete it.
Goodbye.
So now we just have the player starting there.
Okay, for this procedural dungeon we need two things.
well first we need a folder called poor see doo-ra dungeon in here we need two blueprints
which are just actors the first one is the master dungeon which
just call it master room and we need a proof and call to engine generator
again you can call this whatever you want and these are just regular actors the
master room is what we will create all the rooms in the dungeon from.
It will have all the exits that will hook up to each other.
It will have the walls, the floors, the ceiling, everything.
It also have all spawn points.
I'm not sure we're going into spawn points at this time, but if you have spawn points it will get put into.
the master room.
The dungeon generator is the one that will take the master room and stitch everything together in a random way so you will get a random dungeon every time you press play.
So let's start with the master room.
There we go.
Let's add a cube for the floor,
let's just create some basic floor and some walls and we will also start with a collision box collision.
This collision.
box is the one that will make sure that rooms are not overlapping each other.
So we just call this overlap, overlap box, we call the cube floor.
Let's scale up the bullet box 30,
30 xy and c1 do the same for the floor cube and they should be they should match each other right but they are not I don't know why
I mean why okay let's just make the cube so it matches the collision box so what is that 20 20 maybe Again,
guys, I'm not especially good at making tutorials, so you will have to deal with some fumbling around, okay?
But this looks fine.
You can see here that the collision box is a little smaller than the floor and we want that.
We don't want the collision box to collide with the room right next beside it so we need the collision box,
the overlap box to be a little smaller than the floor box.
Okay, let's get back in here.
So now we have a flow.
Let's see if you can find a better material that is not so bright.
Yeah, that's better.
Alright.
Another thing I like to do for things like this is to put an arrow in here,
so I can see which way stuff are pointing,
right, so we just move the arrow up, where is it, it's just a super small arrow, let's just make a super small
a big arrow like this in the center of the room.
So now we know which way the X axis is pointing and another important thing for this dungeon to work.
is that everything needs to start from zero, by now zero, in the world is at the center of this room.
The thing is we need it not to be,
we need to do it like this,
so the center of the world of the room is at this point at the beginning of the room.
Let me explain later on why I'm doing it like this.
So every room will have one entrance.
This will all make a lot more sense when we get a little further into it.
Okay, let's just make some walls.
Let's just clone this box to blink.
and then we just need to scale it down so we can get some wall looking thing I'm not sure how wide I mean you can do this exactly as you want
Okay, that's a bit too wide.
I 7 is a good.
7.5.
if you do it 7.5 then we can maybe we can get it get it to match up here like
this is that right yeah all right let's try and go with
this so now every opening will be like these two square wide I don't know all these terms but the anyways just ctrl C,
ctrl V to duplicate it move it down Let's go into perspective here and see what we're doing.
all right these are cool walls control C control V to paste it move it take one
control V control C control V Rotate it and move it,
let's see from the top,
this is where things are getting kind of fucked up for me right because I'm bad at math and you know getting this
to match up I just don't get it.
So maybe 7 and then we just need to move it in here like this.
See, it's still too big, what do we do, 6, 6.5, ah man, is that it, yeah that looks like bed will work.
I this is why gank the villain and take soak at them long to do.
Control C, Control V, get it over here.
Clone these, Control C, Control Anyways, you can make your rooms as you want.
This is actually not the important part of this tutorial, but now we have a room.
With the four exits, right, and here you can see on the arrow, this is the inter-room.
This is where you will, this part will be put on to the room before it.
Right, so the whole idea is we place this room down and then we will place another room
and move it to one of these exits.
These will be open exits that a new room can get attached to.
So when we spawn a new room, it will get...
one of these exits that we will create later on and it will move the room to the
exit and rotate it so it will be oriented the correct way so let's say
you this is that room you go in and go to the left you get get through the
store and you'll get into the similar room where the arrow is pointing this direction, right?
Does even make any sense?
Alright, so we have our floor now and we have our walls.
Let's just make a new scene over here which will work as a folder.
Add scene, let's just call it three folders.
Let's call these folders.
Then we select the walls, floor, and drag it into the geometry folder.
So now everything is under the geometry folder.
So can just easily kind of close it.
so we can see what's going on here the overlap box we will also make a new folder for that one
and call it overlap overlap folder and we track the overlap box in there
this just call it box one because we will maybe we will get more of these.
Why am I calling it up-lap?
over-lap box over-lap folder there we go I'm sorry I'm an idiot just ignore
that The cool thing about these folders is that in the blueprint we can get these overlap folder and then we can get everything that is in that overlap folder and we will do the same
for the exits.
I let's just make that exit folder right now.
Scene exit.
there we go we won't put anything into this right now also let's remember to get
the arrow and set it to turn off hidden in game so we can see it when it
spawns in the game so we can see what's happening
and then compile this and let's just save everything and I mean let's just drag
in the room here put it at 0 and see if the player can actually use it for a
clay yeah the collisions and everything is working so that's all good and also I
mean let's just make a material and make I mean this is just too bright
dungeon material You should know how to make this material already.
Just some stuff in here in the roughness, in the metallic, set the roughness to 1.
like this,
set a color,
maybe just create,
that will be fine,
apply, let's go into the walls and the floors and apply this material, like this, yeah, that's a, that's, that's more
nice to look at, if I...
If I have to be honest here,
all right,
we have the master room Let's right click it and let's make a
child Blue print out of this and this will not be master room.
This will be Dungeon room
One
let's open it now we will make our exits and we will put them into this
exits folder oh let's call it folder oh I can rename it I need to go into the
master room and then I can rename it in here exit folder, compile, save, and it's exit folder, right.
And let's just make the exits we can make them as arrows.
Arrows are cool because that pointing in the X direction which is very useful for idiots like me who doesn't really
get the whole X system and things are always pointing in the wrong direction and I don't know why.
So arrows are awesome.
Arrow one, let's just call it arrow one.
Let's put it out here, let's make it a lot bigger, so we can see what's going on.
We change the color to, I don't know, green, because that's awesome.
Let's put it at zero, and let's rotate it around so it pines.
out from the room.
That is our exit one.
Copy paste it,
put it over here,
make sure it sits the correct, exactly the correct spot here and rotate it and do the same for the last exit.
like this.
So now we have three exits.
We don't want any exits right here.
Okay, you can always already see I've placed the exits wrongly.
This is the entrance.
So we will just remove this a wall like this and this is to see that is why we made that arrow in the
middle so you don't get confused.
So this is where you get come into the room and then we have three exits where new rooms can get attached to and again we
don't want any exits.
on the entrance room because we don't want another new room going back into the
room that we just came from that will just be a complete mess.
So this is the correct way we can do it.
And what is super cool about this dungeon we're going to make here is that you can just if you don't if you only want one
extra room.
right we can just delete these and it will only take this exit into account and
these holes in the walls will be closed we will do that at the end of the dungeon
generation we will get all these holes and we will close them let's undo this so you can make as many exits as you want.
You can make two exits on each side of the
room and it will still work because the dungeon
will just be checking the exit folder and it will getting all the arrows from that and putting it into a list.
And new room will just be selecting a random
arrow from the list so it's super awesome guys so compile everything and save and
let's get to the next part so this works so let's just delete the room
again let's go into the dungeon generator here and let's just spawn that room.
So, on event begin play, drag out, type in, spawn actor from class.
There we go,
then we can and find our room dungeon room one and then click the arrow so now it will spawn dungeon room one.
An important thing is that under collision handling alright we need to always spawn ignore collisions.
because sometimes unreal are just pushing things around if they spawn and they collide with something so we want we are avoiding that by always born inoculations so where do we want the room to spawn
just drag out the default scene route type in transform world,
get world transform and plug it in here,
press compile,
let's drag in the generator here and put it in zero like this then we can go up here a way to
press play and we can click on simulate now it just simulates the game
without spawning the player character and we can see what's going on so it spawns this room in zero.
Remember that the room has its zero at the entrance.
Alright, so that is working.
That's awesome.
Okay, so the next thing we need to do when a room, when the start room has spawned, is to take all the exits, arrows and put them into
a list.
let's just go into the dungeon room here let's select the arrows here just click them on
click off hidden so we can see them when you when we press play here so now you can see the exits right missing one.
Why are we missing one?
Let's have a look.
Why is this missing?
Oh, because it's hidden.
I forgot to do it here.
All right.
So, just take it and cut.
cool we can see we have all the exits working so we need to go into the
tung-chin generator and from this room the tung-chin room is in here it's in
this node so we can get anything that we have in the tung-chin room let's
go into the master room here we can get all this from here because the room is
here so we can drag out here and say get exits folder so we're just getting
the folder here and then we can get the children of that folder.
You this is the XS folder.
Let's go here in dungeon room one and look at it.
The XS folder and everything that is in that folder are considered children and the XS folder is the parent.
I'm not sure if I always explaining everything about it.
Let's just explain what I can explain because I also myself hate towards tutorial and I have no idea what's going on.
So now we're getting the folder.
Then we can get children, get children components with an S because of there are more children.
And every time we get something with this, when as more, we get it as a list.
So now we're getting the folder, we're getting all the children in the folder, and we need to add this to a list.
Alright, so we can say append array and let me explain in a second and then right-click
this bottom one and say promote a So we are making sure that it's the correct variable we are creating.
and let's call this exit list because this is a list compile so what
is happening here we have a list there's nothing in the list you can see over here
to the right as the list is empty we're getting the folder
we are getting everything in the folder and we are appending it with this list which means that
everything in the x's folder are getting put into the list.
And also I think for some reason we need to this swap these out.
So this one goes to the bottom and this one goes to the top.
I'm not sure how it works but I have just tried that it doesn't work the other way.
Then we connect it.
Yeah so every time we spawn this.
room, we are getting all the exits and we are putting it into this list.
That means that there should be three exits in this list.
Can we test that?
Maybe press F9, see if it works.
Compile, first play.
there's nothing that is because I think we need another step with just
a print string and then remove this error thing and then edit f9 to make the code stop when it reaches this node.
Let's try and see if that works.
See, we have three exits right now, arrow 1, 2, 3, in the list.
So awesome guys, let's just remove this print string again.
So another thing we can do that makes this a lot more clean is that instead of just going straight into event, begin play.
we can delete that one, we drag out and write custom event and then enter and we will call this spawn start room.
So now this is an event and we can mark it like this.
see and we can sign in spawn start room what I like to do is give this a green color
and like this put the green color in here oh Jesus Christ delete this one
so now we have a green color and then enhance the text a bit so we better can
see it so this is spawn start room and to run this code we just drag out from
begin play and then we type in spawn start room and now
the beginning play will play this one it goes into this note which is this
whole code yeah condensed into this one you could also drag it out from the
lift spawn start room in the event craft dragon out we have the same does
that make sense it's just to clean things up a bit more.
Okay so now the exciting part we need to add the next room so we will make a new move this up make a new custom event
right click search for custom
event presenter and we will call this spawnnextroom and now we have created the event we need
to play it after the spawn startroom so we can drag it in from the left as
for our next room and plug it in after the staff room so now everything we put in here
will be played down here that's how custom events work and they are awesome
when i learn how to use this everything becomes much more clear and easy to look at right and it's
It's much to organize if you make things in events like this.
You can also do it in functions,
which is basically the same,
the can do some more,
but then you need to open up functions and go into a different viewport here to work with it,
and I kind of like to have it here so I can see what's going on.
So to spawn the next room we need to get an exit right so we drag in from the left
exit list with those three exits in it so we get it then we can get a random
just typing random array item
and you can right click the blue thing here and promote it to a variable and we
will call this in the top right here we will call this selected exit point and then tie it into the customer event here.
So we're getting the list,
we're getting a random exit,
a random arrow and when we have gotten that random one, we will set it and this means that this is the chosen one.
This is that arrow that has been chosen for the exit.
So now that we have our exit, we need to spawn a room.
So out here, spawn actor from class just like we did with the start room.
And as before, we need to set this one to always spawn, ignore collision.
And see, now we can select our room here.
We have two rooms,
the master room and the dungeon room one,
but we want to make this into a list and then we want it to select a random room from the list.
so right click on this class say promote your variable and rename it to
room list and then we need to set this one over here I don't know what all this
is called but there's a button to the
right of the actor and select array and change variable type and array is the same as a list.
See now it won't work in here.
I cannot put a list into an actor because it just needs one.
and if this is red you just hold down Alt and left click on it and it will go away.
So now we have a room list with nothing in it.
We need to get a random room from the list and we just do it in the same way.
check out, type in random array item and then plug it in here in the class.
Now if we have a list with many rooms and it will select a random room and it will put
that room as the one that will be spawned, it's as simple as that.
that compile and for some reason there's an error here which is the spawn transform
you know for some reason it needs more information than that it that this doesn't
equals zero in the world so to fix it
we just right-click it and say split struct pin then we'll get the
location the rotation and the scale and now it won't complain when we press
compile see now there's no problem so I don't know what that's about so when
this room has spawned right now it's too just spawning in zero in the world.
I actually think we can just get the location.
Anyways, let's move on here.
Let's get back to that.
We to make sure that this room we're spawning is the master room.
So we drag out here.
and then we type in cast,
master, and select the master room so now we're checking is whatever we're spawning in here is this the master room or not and
it is because we're only putting rooms in the room the dungeon room one is a child of the master room.
You see it's using the parent is a master room.
You see it up here on the right.
So the child are also using the master room, which means when we are spawning a child room it will work as the master room.
It knows it comes from the master room.
So let's right-click as master room and promote your variable here and let's call this variable for latest, latest room.
this is the latest room that has been spawned so what is happening here it's
basically taking this whatever room has been chosen and it's sitting that room
meaning that we can get access to it we can drag in like get latest room and this is the latest room This is all,
this is the room in here, we just have it in this small veritable, veritable box, alright?
Jesus Christ.
But I mean, let's see if it works.
Now I should just spawn a new room on top of the other room.
I don't know, is it?
It's not,
hmm, let's have a look, that is of course, because we have nothing in the room list, let's add the one room we have, which is the one hmm.
it's tiring room dungeon room one because the list was empty it didn't spawn
anything so let's try again play do we have two rooms we have two rooms
and they're spawning on top of each other and that is awesome so let me just see
here if I
can let's just stop it if I can get the selected exit point location right
so I can get the selected exit point grab it from here and say get and then get get world location,
I'm getting the location of the exit point and then I'm dragging it into the transform location here.
So now the new room will spawn at the rotation always the same rotation but it should spawn in a different place
now let's see see is this the new one I don't know let's press stop let's try again it's spawning this This the start room,
it has selected this exit room from the start and then the spawn in this room at this point.
Stop and play, see, now it's selected, this point here, where it looks right.
So we got something working guys.
Alright, let's see if we can get the orientation correct also.
Also I was dragging out the exit point, I could also get it from here.
These two are the exact same thing, so I can just drag it in here.
Instead it will be the same thing.
I like to keep the strings short, you know, anyway, so we said it as the latest room.
Now we need to get the orientation.
Actually can I also do?
Actually I'm thinking about, can I just, can I just get the transform?
Get transform, get transform world, get the world transform and get rid of this location and right click and say recombine it to the transform.
and then plug it in.
This should work, right?
So let's try and see.
Yes, start room, new room selected this, exit and it oriented itself correctly.
Let's start play.
Same thing in the start room,
new room,
correct exit,
correct orientation,
so guys this looks like it works and it's it's better than my original dungeon which i'm making this
from so i mean so far so good guys awesome!
work awesome progress okay next thing we will clean this up a little more later
on when we get stuff working we can do it like this so it looks awesome so now
we need to get the latest room the new room we need to get all the exits and put those into the list.
So next room has even more exits to choose from.
So we drag out the latest room and we're getting it.
We can also do it here.
It's the same thing.
So get exit Get exits.
It's in the bottom.
Now we're getting the folder again just as before.
Drag out, type in, get children, components.
Now we're getting all the exit arrows and again we will
a pin just means it takes everything in the list here and put it into another list and
this needs to go into the bottom one.
And then we can get the exit list we have,
drag it out,
get it and put it in here and this list already have three exits in it now we get the three new
exits here and we're adding it to the exit list so it should have six in it
let's just test it out print we just need to test stuff out all the time guys
If 9 to stop it when it reaches point and then put it in here,
so it will be the next thing that is played in our execution here.
Alright, compile.
Let's see.
Play.
Let's see how many exits we have.
We have six, three from the start room and three from the new room.
Awesome, everything works as intended.
That's great guys.
Okay, let's just delete this again.
so now this is working awesome so let's just tighten it up a bit then select
everything press C on the keyboard and then
call it spawn next room and since we're working we're making it green and we are
enhancing the texture and line it up so it looks great here right looks awesome
So another thing I think we need to do in here is that we need to,
when the exit point have been selected,
we need to remove it from the list so it's not placing a new room on top of the same exit that has already been used before.
So we drag out from the selected exit point.
and then we type in remove so remove item in the array like this and then we
drag out the exit list because we want to remove it from the list and plug in
the list here and then connect these up so it's doing
this before it spawns the room and I mean just because it has been removed from the
list doesn't mean that this doesn't know where to spawn because we have already
saved the selected point in the world right that all the existing points are still in the world,
I'm just removing it from the list so when we are using that list later on it won't get the same arrow that we have already used before and we might need to remove
this later on because if this room doesn't work we don't want to remove it from the exit part from the list.
Maybe we want to spawn another room on that exit and maybe that will work.
But let's talk about that when we get there.
Let's fix this up.
Make it look great.
Alright, so the cool thing is now we can just spawn in this room.
the idea is after this room has been spawned we want to spawn it again we want
to get a new room so spawn a room spawn next room okay so now we are
spawning the next room and this one This will cause your computer to crash, I don't know because now it's just spawning rooms endlessly, right?
It this room,
when that is done it goes back and play this whole code,
again spawns a new room, puts it in place, then spawns a new room, puts it in place, right?
So is a...
this will just carry on forever and that is not good so we need some kind of
room counter that can you know count how many rooms we want in the dungeon and
how many rooms we have left so it knows when to stop so let's do that and we
need to do it that before we press play otherwise it will just create an endless dungeon.
So for the room amount we just need to use an integer.
So we go down to the variables down here press the plus and then we get a new variable we call it room amount
and here where it says actor we need to select an integer that is just a number
and it should not be an array so go over here to the right and change it to
single compile then we can type in let's say 10
we want 10 rooms so when spawning next room we want to check if if we have any
rooms left so drag out
room amount so we are getting the chin room number here no sorry guys we don't I
don't think we need to do it here we need to do it over here before it spawns
the next room so drag it out room amount get the room amount.
When this room has been spawned and everything is good we want to subtract one room from the room amount.
So drag out, click the minus or subtract button on your keyboard then select subtract.
and type in one so now we are subtracting one from the room amount and then we need to set it
to the new so drag out the room amount again and select the set room amount right so we're
getting the room amount we are subtracting one.
And then we are setting it again.
So now it's only 9.
This is the new view update in the room amount file here, this one.
This one and this one is the same.
This one has 10.
When we have to subtract the one, then it has 9.
Which means this will turn into 10.
into a nine.
Drag it in here.
When that is done, we need to see if we have more rooms than zero.
Yeah.
we are getting the room amount again, we get it and then we want to see if it's bigger than zero.
So type in this big type in this,
I don't know what this is called in English, you can also just type in greater maybe, yeah greater.
if it's greater than zero, down B and left click and you will get a branch.
You can also right click, type in branch here, same thing.
Put the red one into the red one.
drag this back here so if the room amount is greater than zero we want to
spawn a new room if it's zero if it's not greater than zero we will do
nothing we won't spawn any new one
We will stop the generation first compile and let's hope everything is an order first
play we should have a dungeon now with 10 rooms or maybe the mask probably don't work one too 3,
4, 5, 6, 7, 8, 9, 10.
10 rooms and a start room.
Alright, first play again, we get a new layout.
And all these exits you see here, they are all getting added in the list.
So all, if we spawn a new room, right now.
now then it has all these exit points to choose from for the new room.
Does it make sense?
Getting a random dungeon.
this is awesome guys the thing is that we might not see it here but let's say
it's adding a new room to this arrow and it places a new room here then we get a
new arrow over here and then if it selects that arrow and places the next room it will lie on top of each other.
because we have no way right now where we're checking if any rooms are
charging another room or overlapping another room and we want to make a rule
that does that if a room is getting placed on top of another room or hits another room then we want to delete that room.
and we want to try and select a new exit somewhere else and place the room there.
That is the the hard up hard to do but that is super important.
Okay so that is just super cool.
for now let's fix the overlap thing it's not really a now but we can also if you go into
the dungeon generator go to the room amount you can save it to 30 right compile then we can try
again and we will get a dungeon with 30 rooms.
Some of them might be overlapping now,
we can't really see it because they're all the same material,
so there's not really any flickering or anything that will tell us that anything is overlapping.
But probably, you can see here guys, I found a room that is overlapping room number two.
and room number 18 on top of each other so that is not good and we need to fix
that okay so we need to fix this overlap thing just go in here make this pretty like this Let's go down here.
Let's make a new custom event.
Right-click custom event.
Recall this ad 01.Lapping.
Rooms.
To list.
So now we want to figure out if the rooms are overlapping any other rooms.
So drag out the latest room,
the latest room is the newest room that we have placed,
we want to check if that is overlapping with anything which is why we made
overlap box so drag out from this room type in overlap what did we call it
folder right folder get overlap folder just as we did before then we're getting
the children get children components so now we get everything in the overlap
folder and now we have to do something called for each loop and that is just
something I don't really get and and don't
like because it's confusing as hell so drag out from this array type in for each
loop this means it will do this whatever put in here it will do that for
each thing that is in this list each of the children will be going through this code.
So we'll drag it in here and what do we want to do for each of them?
We to get the box collision component.
Let's go into the master room here.
This overlet box you can see if If you hover over it, it box collision, that is what this component is called.
So we go into the dungeon generator, drag out here, then we need to cast to that box collision.
Box component, okay.
so here it's called box component I'm guys confusing as hell but we select this one and we're
getting we're making sure that this all at box is a box component I don't know why it says collision here
but when it's a component so I'm a bit confused on some
things but after hours of fiddling around with this this is the solution all right so now we want
to get anything that this box is over 11 and put that into a list so we drag out we say get over
lap Get over 11 components.
We want to see if it's overlapping any other box collision components.
And we want to put those into a new list.
So type in append, append array and we need to plug it in.
in the bottom one and then Alt-Lift-click to remove this one and then plug it into
the cast over here and then right-click the empty pin thing and say promote a
and we will call this new variable overlapped list so everything that is getting overlapped is getting put into
this list so we're checking the box in the room if it's overlapping with any
other box then we will put it into the list if it's not overlapped having it will not put anything into the list.
The reason why we are using it for each loop here is because in the room if we are adding another overlap.
box.
Let's say you have a room that is just copy and paste.
There room that goes like this.
You cannot get a box that covers this so we need multiple that these all have boxes to check.
So we can have more all eight box all that boxes in in one room.
That is why we're checking all the overlap boxes Yeah,
and if they are all having anything we put it into a list and Then later on we check if if there's anything in this list
we will delete the room because that means it's overwhelming.
If there's nothing in the list then just place the room and move on.
Okay we have I don't think we have any real way of checking if this is working so let's just caption this and call.
it.
Check for overlapping rooms.
Make it bigger so you can read it.
So we won't color this screen because we don't know if it works yet.
So now we need to fire this off.
So we are getting this custom event we just made,
drag it out from the left,
add overlapping room to list, we will run this code which is all this up here, contents down to this one.
So drag out.
and we make a branch.
A is just checking if anything is false or if it's true.
So let's get the overlap list we just created.
Let's see if there's anything in the list so drag out,
type in empty So, if it's not empty, if this list is not empty, we will go and delete stuff.
If it is empty, which is this one, we will move on.
okay so let's see if it's not empty that means it's overlapping then we want to
destroy the room destroy destroy the actor what actor do want to destroy
we want to destroy the latest room which is the one that is overlapping another room That room is getting destroyed,
but then we don't want to stop the leverant or the dungeon right there.
We to keep going, make a new room.
So we drag out here, type in, spawn next room, we do everything again.
If I click on this, you'll see.
We are getting new exit points, we spawning new room, all the stuff we are adding exits to the list.
We subtracting one from the room, of course.
If a room is all we have, we don't want it to remove a room from the room amount, right?
Because the room is not getting placed.
is getting destroyed so we don't want to subtract one right here but let's figure that out later on.
Another important thing we want to do here we want to clear this list so it's empty for when a new room is spawning so it doesn't just add
in all these collision boxes every time a new room spawns every time a room spawns and it's fine
then we need to clear the list so it's back to zero.
so we can get some new colitis in so we can check those and that's easy to do
we just drag out the all app list get it drag out here and say clear
and then just make room for it put it in here on the true So,
before destroying the room,
it's clearing the overlap list,
so we can get the next room that is spawning,
we'll put its overlapping boxes in the list,
and you can copy this, copy copy copy copy this, copy paste and then we need to do the same if this is false.
We to clear the list no matter what.
If the room stays we need to clear the list.
If the room is destroyed and we're starting a new one we need to clear the list.
So I think we can actually go up here.
Get the where we are subtracting from the room amount you can cut it out,
cut, control X, connect this up and then we need to put it down here for if the room is successful.
Then, we will subtract one.
If the room is getting destroyed, we will not subtract it from the room amount, right?
Because we will be getting a new room to test if that will work.
Yeah, okay.
So what's next?
We need...
to play this somewhere this needs to go in somewhere but where do we need to
plug it in probably before this so the room is getting placed and we're getting
all the exits we want to wait with that also move it over here can we make this a
little prettier with some more space so when the room is placed and it is moved
to the right look
Location and all then we need to check if it's overlapping anything
We can we can make a new custom event here custom event
Oops
and we will call it check for one lap check for
over lap y k and i spill over lap today that is nuts
so when this one is getting played it will play this one which is this code up here,
when that has been running then it goes on to play the next part,
so we need to fire off this check for overlap and I think we need to do it in here,
so grab it from the lift.
and plug it in.
So if all this is good we are moving on but I'm doing something wrong here.
I think we need to put this code here and down in here somewhere right so let's say the room is successful then we will be
adding okay so cut this out we will add this down here
we will subtract one room and then we will add all the exits to the list so what's happening
up here let's remove this one we don't need to spawn next room because we can do that down here too.
Copy this over, like this.
So if the room fails because of overlap it clears the list,
it destroys the room and it spawns to try against spawn in your room.
If the room is successful it clears the list, subtract one from the room among them.
it adds all the exits to the exit list and then it will spawn the next room but
we of course we need to check if the room amount if you have anything more
left in the room amount so copy this down or cut it out and plug it in here.
Before we spawn the room we want to check if there are any more rooms we want to spawn.
If there is a true, we spawn room.
If it's not true, we stop the room generation.
I think, I mean, right now I'm just improvising, delete this one, but I mean, it should work.
There's a chance I'm screwing up the whole tutorial right now, guys.
That is kind of, yeah, we'll see.
let's see guys if we can get it to work this is exciting exciting times play
oh okay I think I know what the problem is it that is the collision So, in the room we get the overlap box here.
I think that is just colliding or whatever with everything.
So go down to the collision here.
Collision presets.
generate all that event yes can step on no let's set this to custom no
physics collision that is fine only or lapping and it's only it's all lapping with
everything
right so the thing we need to do we need to go in and make our own overlap
channel so go into project settings and go down to collision And then we need a new object channel,
a new object channel, we will call it a room or a lab, room or a lab and we will set it to ignore.
press accept then go back to the room master room I think and then over here
we can set the type that this overlap is it's not the wise maybe I need to
refresh all notes maybe over there we have a room on one lap so we set this
to room overlap now this overlap box is a room overlap and click off everything
so it ignores everything except for room overlap we will set that to all of them Holy shit that's a lot of overlaps.
So now this box should only overlap with room overlap which the box is set to so it should only overlap with the you know
a similar box in another room.
Let's see if it works.
better now okay play yeah something infinite loop so okay let's try and
put in a delay here so we can see what's going on delay 0.5.
So every time it has sit down a room, it will wait a half second before it tries the next room.
Let's set the room amount down to 10.
Let's if that's even possible.
So now it's deleting rooms and it's placing rooms.
Is that it?
One, two, three, four, five, six, seven, eight, nine, ten, and a start room.
It looks like it works.
Let's try again.
Yeah, you can see there's no arrows on top of each other.
sometimes there is but they're getting deleted 1 2 3 4 5 6 7 8 9 10 11 yes
something is working so what if you remove the delay Okay, we'll just give it a So it looks like the dungeon is working.
To make it look cool, we can just make it short, shortily, like, two, three.
Now you can see the generation which is awesome.
And we're getting 10 rooms plus a start room.
Let's try and make a new and shorter delay, and let's try and put in some more rooms, I mean some more room amount.
30, let's see if it still holds up.
Yeah.
Looks good.
So I'm just kidding, we have 30 rooms here, 31 rooms, yeah.
That's great guys.
So this town here is working, this is working, let's put it in green.
This part down here is also working, it seems, delete if overlapping.
Delete latest room if overlapping,
screen, bigger text, Okay guys, I do think that we need to move this, where's this one, oh I have unplugged it.
We need to move this.
cut it out and put it down here where we are sure that the room is working just make will be selected exit point.
When we are certain that the room is working we will remove the exit point from the list because it means there's already a room there for the next
one.
Let's see if it gives us any errors.
And you the dungeon here is just getting completely rained.
generated.
There's no structure in it at all.
Just the legs and random exit point and places a room.
So, and you can see when you have a shed ton of the same rooms with three exits, it turns into something like this.
but I mean let's try and make a few different rooms and put them in so we have this room one with three exits.
Let's duplicate this and we'll just call room two then we can go in here.
and whoops my bad what just happened holy shit okay that looks okay that looks
right so for room two we can come kind of just remove the ones on the side.
So no room can spawn here.
And we can just close these holes in the walls.
Something like this.
I don't know,
5, 5.5, yes it works, copy paste it over, so now we have this type of room, compile, save everything, so this room too, we need to put it into the room
list.
So let the room list from the left open, make a new one and paste in room number two.
So let's see how that works.
See, we have one here, we have one here.
We have a lot over here, so we get these corridors.
It's really not that different, is it?
So, the thing is, we can also go into the dungeon generator, put in more of these rooms too.
So, just kind of duplicate it a few times.
So, now there's a much bigger change that these rooms will get selected.
So here we get a lot more corridors now.
Let's go in and make, let's make a few rooms that only turn left and only turn right.
So we have,
so room number three, let's make it so it only, okay let's not duplicate that one, delete it again and take room one.
duplicate this one and open this one rule number three delete the front arrow and the right arrow then fill out the holes Oh,
5.5, 5.5, 5 what?
Oh man.
I mean this coordinate systems anyways now we have a lift room
Let's clone this duplicate and make a right room and so move this one over here like this and move the arrow over here.
you can add as many arrows as you want.
Just make sure you have an exit.
So let put in room 3 in the generator and room 4 in the generator compile Let's see what we get,
same thing, let's try again well it is a procedural generator, dungeon.
There's no denying that, now it lacks some exit points because it ended up Yeah, closing itself in because it lacks exit points.
That is not a good thing.
I've never seen that before, actually.
Maybe just make sure that you have enough exit rooms.
Alright, just maybe plug in some more of these rooms, number one.
So we have more exits to work with,
I mean this is by no means a perfect dungeon at all it does have some problems but this is a really good start right to get you to get
you going so now we need to close off those exits right so when the tension when
the tension is done we get all these open whoa these open exits
and we want to put a wall in there so the dungeon is completely closed off and
let's do that now so in the dungeon generator it's just making a little more pretty we will make a new custom event,
custom event and we will call it close polls and let's check if sit selected exit points are getting removed,
oops, so find references, he's setting the exit point here, we're getting it for the position of the room and then we're
removing it,
so it is getting removed when a room is successful so that's good let's go down here so everything let's get the exit
list here everything that should be in the exit list now open holes but of course we also get let's see room amount.
Let's just turn it down a bit so I can show you here.
We are also getting holes here inside the dungeon.
this holes need to get close to like this one needs to get close to what I'm
trying to say here is that there's an open there's an exit point right here
that has not been removed because there's no room has been put placed on it.
Right this room here comes from here and not here so no room has been placed on this arrow but we are going to put walls there anyways so
let's get back to the generator.
So exit list We will make a for each loop again,
these same things, so on any every exit we just want to spawn an actor.
like this spawn actor from class and we will get the transform here world
get transform get world transform
here from this exit we are finding and plug it in and remember always spawn ignore collision
compile we need something to spawn so we will make our what we call it
Make a new actor here blueprint class actor
We call it int wall I
Mean you can call it what you want doesn't really matter
Open this We can take our dungeon room and we can grab this piece for example,
copy, paste it in here and move it to zero and set the rotation to zero, but this this
This has the size we want for the wall holes,
move it up so it's at floor level, compare it and let's plug it in here, select in here.
wall go to dungeon generator it's getting a little confused and now guys I'm sorry about that but
again tutorials is not my force plug it in here in wall compile
we need to play
this close holes we need to play it where do we need to play it we need to play it down
here when there are no more rooms to spawn Timing holes, close holes.
This should work.
When there are no more rooms in the room amount to spawn, we will close all the holes.
Let's see if it works.
See, it closes the holes.
That is amazing guys, we just need to move it in place.
So we need to move with a little love and a little back,
I think, I mean, this is just you know random up and back so it's on the line let's see if that's enough It is.
It worked.
This is the start room.
You to put in a wall here in your start room.
Nothing will spawn from this point.
So, you know, you'll always start with your back against the wall in this maze.
That's no, I mean you could do the same.
But it's easier just to make the room with no holes in it, the stop room here.
We can even, you can put in a small delay so we better can see it.
delay one second compile play see all holes are closed and of course in your
labyrinth you need to make the rules so they kind of make sense and
the The end holes that is getting put on need to fit in with the rest of your dungeon design
but of course that makes sense.
This is just clean cubes I'm using just to show you how to make this.
that's it guys we have a finished dungeon here
the last thing you might want to do is this is the last part in the creation right
you can make you can make a boolean called dungeon complete,
compile it,
that is set to off,
the dungeon is not complete,
so when all these holes are put in,
then drag out the dungeon complete and set it here and put a check mark in it that means the
dungeon is complete you're gonna make a print string that's this
dungeon complete so we get a bright color here make it last for 60s 10 seconds right when we
play dungeon complete and that just means you can get this on other blueprints
like on your player character if you want to wait with spawning him until the
dungeon is complete or maybe you want to fade in the player UI but only when
the dungeon is complete Then you can have a loading screen,
you can remove the loading screen when the dungeon is complete, right, that's kind of how it works.
So you check if the dungeon is complete before you spawn the rest of your game.
And of course we need to just make sure.
is pretty so close holes green because it works size of 30 so you can read the
text and there we go and it doesn't look too bad does it?
just align everything so it looks awesome put the event begin play at the
top don't put anything around this so you can easily spot it and event begin
play spawn start room start room here when that is done spawn next room and that
will just do and fix all the collisions and when there's no more numbers in the room amount,
the dungeon will set itself to complete, that's it.
And I'm sorry if this tutorial was a little messy,
I mean I'm still trying to learn these tutorials but and it takes a long time to make and I was fumbling
around in the middle and stuff is not working but again I think it's
important for you guys to also see when stuff is not working and you will see how you can kind of solve it.
I can see here with also need to delete this one not using it just make things pretty right remove
all this space make it make it easy for you to understand where to find things divided up into these custom events,
it will make your life much easier.
I mean the thing is right now what you need to do for your game here is to go in and make
more right let's make for example let's clone room two here duplicate let's make a
hallway room right that hallway room so just go in here make the walls shorter let's just try and do it like this,
like this, right, like this, smaller, Remove these.
Oh, that's another thing.
Oh, that's important.
All these walls.
And because Because these walls are in the master dungeon room.
here that means we can't delete them which is a big problem so we need to go
in let's see here room one let's copy all this all the walls and the floor copy it,
go back to the master room,
delete it from here,
compile, this should be all we have in the master room, you can delete the arrow when you don't need it anymore.
So we go back into our rooms, room and they're gone.
So go into the geometry folder and paste it.
It's not in the geometry folder but just move it down.
Oh it doesn't really matter where it is.
let's just delete these things we're not using so rule two see everything is
missing now except these new ones I made so geometry folder pasted in put it down in the geometry folder So that is room 2.
And know this is annoying, but it's just important, paste it, drag it down to geometry folder.
like this.
And since we already put them in, it's not that big of a deal.
Dungeon 4, paste it, move it to the folder, and it all looks right.
Dungeon 5, And paste it, move it to the folder like this.
And now because these are not part of the master room anymore, now you can delete them if you want.
we'll be back in place here for our hallway room so delete these move these out like this and what is this 7?
7.5?
7.5?
again we can make duplicate this we can make some pillars out of this duplicate
duplicate them move them around doing this to try and show you that the room
showmaking for your game here will be awesome like the more rooms to make the
more special
dungeon becomes the more variation you will get into your dungeons also this
one need to scale down to and it needs to kind of go in it
cannot stick out so compile get this dungeon room 5 go into the generation
room list let's remove let's put it in here 1 5 2 3 4 we should get some hallways now We got one hallway,
and as you can see already now the hallways are making a dungeon a lot more interesting, we can de-clone it.
Just killing the hallway,
so we have more of them in the list And see did you see there was a hallway right here that got deleted
That's not a lot of hallways probably and even the hallways are getting these int holes repaired.
That's it guys, you haven't even tried to run around in the dungeon yet, see?
What a pretty dungeon.
The last thing we need to do guys is to make a fail safe for the
dungeon so it will prevent it from if the dungeon breaks let's say it after the
star room it spawns four rooms that can win turn left that will mean it will be
like a snake that turns around and it will bite itself in the tail right and
and it won't be able to create a
other rooms because there are not any more exits you know what I mean and if
you're unlucky and there's no more exits for the dungeon rooms to spawn it will
just delete the rooms and transform them again and delete them and transform them again and it will do that for eternity.
So we need to make some kind of timer when the dungeon starts.
The max amount of time you want to spend on creating the dungeon and if the dungeon takes longer than this time it will reset itself and start
all over with a new dungeon and hopefully get a better result this time.
It will just your game from crashing and you have to exit out of the whole game and boot it up again to try again.
So that's what we will be doing now.
So we will make a new custom event, custom event, call it start dungeon timer.
and we will make a timer by event set timer by event this timer will run every
second and it will be looping so when this is fired off
this will trigger something every second so drag out here let's make a custom
event and call it check for dungeon complete and now it's a good thing
that made up to
it dungeon complete boolean early on so let's just make a print string here
print string as we can see if stuff is running the time in running timer and we
will have to start the timer
down here in the event begin play so we can just start the timer after the first
room has been set where is it over here start dungeon timer drag it in plug it
in here with the rest of the boys and now Now we can see here this test,
but another thing while we get the room amount, click it and over here to the right click instance visible and expose unsponed.
This means that we can select the tangent generator over here.
And we will have the room amount right here.
So can just change it here instead of inside the generator So now it's 30 But it will still be 20 in here, right?
So it's not the same thing If you want to make it back to the original just click on this arrow it goes back to
whatever it is set to inside the dungeon so set it to 30 we'll see if the print string is working
yeah see it's running timer every second it prints out running timer
the problem now is that we need to make it stop when the dungeon is complete or if it takes too long,
we want to reset everything.
So we can start by stopping the timer when if the dungeon is complete.
So on this timer, by event, drag out from a churn value and promote your variable.
This is something I don't really understand,
but it's something I'm doing in my game, The Adventures of Gone, when I'm creating my dungeon in there.
So, call this timer handle, whatever that means.
Yeah, what else, then go down here to where the dungeon is complete and drag out the new
timer by handle no idea what that means but it will stop the timer if the
dungeon gets complete right if the dungeon gets down this road and completes itself so let's see if it works Timer's running,
dungeon complete, and the timer stopped running.
So a good thing.
Great-looking dungeon, right?
So let's go back into the generator.
Now we want, let's make a branch here, hold down B, left make a branch.
So now we want to get, right click and say get game time.
getting time in seconds also I'm not really sure what this is I think that
is something that runs when you press play up again I'm not sure guys but if
this one turns out to be greater or equal this number, let's say 5, let's just get some more space here, right?
If the time has been running,
for five things or longer it will be true and in this case we want to open level by name
I mean this is a kind of a hard car way of doing it so we're just closing down the
level and open it again I'm sure there are different ways of doing this,
but when you close the level down,
nobody again, you're sure that nothing is left behind in the level, that you have no idea about or can control, right?
So in this case, the level is called third person.
map.
Let's see if it works.
If timer is greater than 5 seconds, let's just set it to 2 and then have 2 seconds to create a 30 room dungeon.
Yeah, see, it cannot place down the 30 rooms before the 2 seconds is up, so it keeps loading the level again and again.
And this is what we want.
Now we can control how much time we want the dungeon to try.
try and complete itself.
So stop it.
Let's try and set it to 15 seconds.
Now it has 15 seconds complete itself.
It did.
It completed the dungeon under 15 seconds and it stopped the timer and now we can just play.
Let's try again.
completed the dungeon does it have 30 rooms it has 30 rooms so maybe maybe we'll complete the dungeon in maybe eight seconds Yes,
so it's about finding you know the max amount of time you want to spend in the loading screen.
Sometimes the dungeon takes longer if it's if it keeps overlapping other rooms and we create new ones.
But another thing we want to do here,
first of all we want to make this a variable promote to variable and we will call it max dungeon time and that is 8 right here.
now.
So of course you want to set this dungeon,
makes dungeon time, you want to increase it if you are increasing the room amount for the dungeon.
I mean and you can do some calculations so you kind of you just multiply the dungeon.
in time with the amount of room you have.
I mean something like that but so let's clean this up make it pretty caption this call it dungeon timer works.
So there we go, we can get this out of the way and move it at the top.
So we always have people.
can play at the top.
And now your dungeon should be working, you just have to balance the max dungeon time with the room mount.
I think this is enough guys, this is very stressful for me especially at that point where everything fucked up.
but we got it fixed and it's absolutely fantastic that's it guys that is how
I create a procedural generate dungeon I hope you enjoyed the video I hope
you got something out of it I'm and I'm hoping you will create some awesome
dungeons using this
system and even better I hope you take it to the next level and do something that
is even more awesome right for your game so if people like this video
I'm considering making a part two where we can talk about how to spawn different things in the dungeon enemies gold coins,
treasure chests, things like that let's talk about that if we get there.
Anyways, have a nice day guys and see you next time.
Lingua di traduzione
Seleziona la lingua di traduzione

Sblocca altre funzionalità

Installa l'estensione Trancy per sbloccare altre funzionalità, tra cui sottotitoli AI, definizioni di parole AI, analisi grammaticale AI, parlato AI, ecc.

feature cover

Compatibile con le principali piattaforme video

Trancy non fornisce solo supporto per sottotitoli bilingue su piattaforme come YouTube, Netflix, Udemy, Disney+, TED, edX, Kehan, Coursera, ma offre anche traduzione di parole/frasi AI, traduzione immersiva a tutto testo e altre funzionalità per pagine web regolari. È un vero assistente per l'apprendimento delle lingue tutto in uno.

Tutti i browser delle piattaforme

Trancy supporta tutti i browser delle piattaforme, inclusa l'estensione per il browser iOS Safari.

Modalità di visualizzazione multiple

Supporta modalità teatro, lettura, mista e altre modalità di visualizzazione per un'esperienza bilingue completa.

Modalità di pratica multiple

Supporta dettatura di frasi, valutazione orale, scelta multipla, dettatura e altre modalità di pratica.

Sommario video AI

Utilizza OpenAI per riassumere i video e comprendere rapidamente i contenuti chiave.

Sottotitoli AI

Genera sottotitoli AI precisi e veloci per YouTube in soli 3-5 minuti.

Definizioni di parole AI

Tocca le parole nei sottotitoli per cercarne le definizioni, con definizioni alimentate da AI.

Analisi grammaticale AI

Analizza la grammatica delle frasi per comprendere rapidamente il significato delle frasi e padroneggiare punti grammaticali difficili.

Altre funzionalità web

Oltre ai sottotitoli video bilingue, Trancy fornisce anche traduzione di parole e traduzione a tutto testo per pagine web.

Pronto per iniziare

Prova Trancy oggi e scopri le sue funzionalità uniche

Scarica