Godot Version
4.3 (planning on changing to 4.4.1 at some point but i forget a lot and I cant rn)
Question
I’m trying to make what chatgpt calls a ‘modular room based dungeon generator’ and it actually got it working, supprisingly, but i honestly don’t like the idea of vibe coding my way to a game, so I tried having it explain what it did to me. it explained it… I think. I’d give the like 200 lines of code it gave me but parental restrictions closed godot lol. I wanna actually learn / code this game, but idk where to start even after chatgpt explained it. i’m not a robot i can’t just absorb that knowlege
so I was hoping sombody here could help me out with it. I have some rooms but idk if I need to make a seperate room for each and every direction because brute forcing that kinda stuff is absolutly wild in my opinion. I used the walker method from heartbeast once before but it felt too small and I didn’t really like it (taught me some important stuff though) and I always thought having a system where you could place premade rooms randomly was neat. so if someone could help that’d be awsome
Placing premade rooms randomly is relatively easy in the abstract. A question or two:
-
Do you want to be able to see the map, or is this a first-person game? If you want to be able to see the map, the map needs to make euclidean sense, whereas if you’re “in” the dungeon then it doesn’t matter much if the layout makes sense as long as the doors all line up.
-
Do you want the rooms to fill the available space, or can there be gaps?
-
Is this 2D or 3D?
I’m assuming you’re thinking top-down 2D dungeon crawl in the roguelike sense (that is, the original Rogue…). In that case, if you don’t care too much about packing the map, you can treat the map as a grid, and the rooms as shapes that fill grid cells. Set up a map that’s all empty cells, then drop rooms on it at random locations; if every cell the new room covers in the grid is empty, the room fits, and you write that room’s number in all the grid cells it covers. If it doesn’t fit, roll the dice again.
If you give your rooms a margin around themselves as grid cells, it gives you a place to put corridors later.
Once you have your rooms placed, you can start hooking up corridors. Those just need to connect the pre-defined doors in your pregen rooms. You can hook those up using A* pathfinding.
That’s just an example of how the problem can be solved; if you google for “dungeon generation algorithm” or the like, there are tons of pages about it out there. People have been writing solutions for this problem since Rogue.
1 Like
ChatGPT will lie to you and make stuff up - especially with Godot. Don’t use it to learn how to code.
There are some really great tutorials on this for 2D and there’s even a plugin that you can use to do it for you in 3D.
Remember when I said ChatGPT lies and makes stuff up? modular room based dungeon generator is a sensible-sounding name that doesn’t actually mean anything. The common term is procedural generation.
Google “godot 4 procedural dungeon generation” (or just click the link). Then watch some YouTube tutorials. They will explain to you how they work, and help you build one step-by-step.
2 Likes