Procedural Dungeons in Godot 4 | Tutorial

preview_player
Показать описание
--------------------------------------------------------------------------
This is an implementation of the algorithm the game tiny keep uses in godot, using gridmaps.
resources I used :

video chapters:

0:00 - Intro
0:29 - Scene setup
3:27 - Algorithm overview
5:11 - Dungeon script setup
9:32 - Drawing a border
11:21 - Placing rooms (Explanation)
12:10 - Placing rooms (Code)
20:09 - Hallways
23:35 - Finding MST (Explanation)
24:42 - Finding MST (Code)
27:30 - Adding edges to the MST
28:50 - Placing doors (Explanation)
29:31 - Hallways and doors (Code)
25:12 - Seed customization
36:20 - Dungeon creation (Explanation)
37:06 - Dungeon creation (Code)
39:21 - Cell logic (Explanation)
41:35 - Cell logic (Code)
45:54 - Finishing touches
46:33 - Final result
Рекомендации по теме
Комментарии
Автор

Quick note:
In the tutorial I failed to mention that if you want to bring the dungeon generated in the editor over to the game, you also have to set the owner of each of the cells you add as a child.
this can be done by adding the line :

dun_cell.set_owner(owner)
after add_child(dun_cell) at 39:21

This is because when saving scenes godot needs to know each node's owner.
Sorry for the neglect.
I'll correct this in the github repo

quwatz
Автор

Really awesome tutorial ! Thanks you for making this tutorial, which will undoubtedly help many people in the Godot community.

Some minor things that could be done differently (Without wishing to be demeaning ! Quick disclaimer : I'm by no means a professional....) :
6:24 : no need to declare the set function, add ":" at end of the variable line, on next line write "set(value) :" instead of the function, and finally the code.
13:04 : use "randi_range(min_room_size, max_room_size)" which is more clearer than the modulo one
19:15 : take advantage of the vector3 operators : var center : Vector3 = Vector3(start_pos) + Vector3(width, 0.0, height)/2.0
33:52 : here, the type can be inferred, so you can omit the type name : var pos_from := Vector2i(h[0].x, h[0].z)
43:04 : only one simple handle_all function with an extra parameter key could very well have done the job :
func handle_all(cell:Node3D, dir:String, key:String) :
match key :
"" : cell.call("remove_door_"+dir) # for handle_none
"00" : cell.call("remove_wall_"+dir) ; cell.call("remove_door_"+dir)
"01" : cell.call("remove_door_"+dir)
and so on...

Again, great work ! Nicely explained and well done. New subscriber.

yvanvan
Автор

29:32 "So, assuming you understood everything"
Bold of you to assume I understood *anything*

ChainZGER
Автор

Insane video. Its great that you not only explained code but showed the logic behind the code with the animations before. This makes it very easy to Understand. Thank you for this great Video!

EmGi_
Автор

I have been nibbing at this for a good month or two now(nowhere close to where you got, time and struggle learning too), also I was not using the grid system yet.

This video is so incredibly good for me that I have downloaded it in case your account explodes I will always have it lol. But seriously, this is an amazing achievement for roguelike dungeon games on Godot, thank you so much for your effort and sharing, I know is not easy to reach this result(at least for me was being really hard).

Also this is so incredibly flexible too! I want to add several floors and I think I can now, will definitively share it once if no one beats me to it (pls some beat me to it xD)

Now just to create nav meshes based on the grid, spawning systems for loot, mobs, secrets, dynamics, art, sound, tons of work and you got yourself a nice rouge like dungeon game lol!

Again I was 2 mins in and I subscribed and liked because some people has done it but no video comes close to explaining this well enough as you did, not even mentioning godot 4. You say this could be not "optimal" but im forking this and doing my best to upload any improvements (if any). Really exiting 11/10 content.

EDIT: Almost forgot the "quick" text popups are hilarious lol

AirmanCS
Автор

Magnificent work here. Perhaps I can convert this for my 2d game in the future.

mythology
Автор

Wow! Amazing code and excellent explanation! I'm studying it to learn about procedural generation. I'll recommend your channel to my friends, hope you make more videos!

LevetAriel
Автор

Thank you for this amazing tutorial!
I made some modifications to the way the room are generated to instead use pre-made ones and it works really great

Syvies
Автор

no need for the disclaimer...no one is perfect and if someone is going to judge you for english being your second language or that you laptop is maybe old or something..who cares..you are providing people a valuable service...(liked)

nowherebrain
Автор

Ok I finally mastered the concepts on this video, wanna thank you a lot for this, really gave me that initial push on procedural generation. Now im creating my own Astar algorithm to search in 3D add stairs and whatnot, finally using triangulation on 3 dimensions and such, but got to say thanks to this video, before it I was really stuck... I would like it 100 times if I could but I guess a second comment will do

AirmanCS
Автор

Thanks for the tutorial, I've been thinking about doing something similar but most of the tutorials I've watch never really went in depth, thanks for the video.

sleepymushroom
Автор

Incredible video. Absolutely crazy! Thank you for the in depth explanations.

TNoire
Автор

Great video man, I'm currently watching it through on my second monitor just out of curiousity because I love procedural related topics and this is a great system you made

seepsoda
Автор

I'm not actually interested in dungeon generation but your video is a great resource for procedural generation from the editor !

belgarathlesorcier
Автор

Good sir, you have an amazing talent explaining things. Thank you!

Kireita
Автор

Searching for a tutorial for this for a long time, thanks!

giampaoloschembri
Автор

Awesome work, vastly more advanced in Godot than i can use, but love the zoom / outerglow use to target parameters 🤟

generrosity
Автор

This is the most useful video for learning this I have found thank you. I've been trying to use chat gpt to learn how to do this

alfredorourke
Автор

I've always wondered how this method works. Thanks for sharing this.

jeffreystephens
Автор

Thank you so much bro. It took me ages but I managed to learn a lot and found out how to do this in 2D!

meromero