Which approach to use for MeshLibrary items for 3D dungeon game

Godot Version

4.7.1

Question

I’m new to gamedev and Godot, but have programming background. I believe that building something is a good way to learn new stuff, so I try to make a simple 3D dungeon crawler/exploration game just to understand things.

I already implemented maze/rooms generator and now it is time to make actual 3D scene. After reading docs and some googling, it seems to me that I should use GridMap with MeshLibrary for this. However, I’m a bit lost with which approach for MeshLibrary items to use. I see the following options:

  1. Make my meshes solid cubes (e.g. 3m x 3m x 3m). This way I can easily place these cubes in the cells with walls and get desired look. I even can optimize it a bit and do not place cubes which are “buried” inside the walls as they are not visible anyway. However, this approach has a drawback: when cubes placed diagonally, e.g.
WALL   FLOOR
FLOOR  WALL

cubes will touch only with one edge and there is a risk that it will look like a gap or there will be “falling/seeing through textures” behavior.

  1. Instead of placing solid cubes, place a more complex mesh on each cell depending on the number of walls surrounding floor tile. For example, if this is a dead-end my mesh will be a 3 rectangular shapes on the 3 faces of the virtual cube, as in the image below.

    Of course these shapes will have volume, e.g. 3m length, 3m height and 0.4m width. They can be placed either on the edges of the “virtual” cell or centered over these edges so that inside the cube distance between the “walls” will be about 2.6 m and “walls” will extend outside of the cell a bit.
    My understanding is that in this case wall will form sealed shell around walkable space and prevent gaps even at the diagonal connections. But I’m not sure about placement in this case. Should I center my planes on the edges or align them with edges of the “virtual” cube/cell.

Which approach should I choose and why? While this is a learning project I want to build it following best practices.

I’m not sure that this answers your question, but…
I build dungeons and mazes with Blender; it’s software made for it, and very good for it. Not that difficult, I find. Godot is not, in my view, the best tool for creating the in-game objects that I use, but excels in the programming aspect. So…
Choose horses fit for the courses, and make game-making just a little less difficult. Design your dungeon, build it with Blender, then import it into Godot. Depending on the movement technique you choose, it doesn’t have to be grid-based at all (although it does make modular construction far easier…). Here’s a short video showing a couple of minutes of the Entry into my Dungeon. All modelling is Blender, all action is Godot…

… and here’s a view of part of the Dungeon

… made like this in Blender…

… and seen like this in the Godot editor…

You may, of course, have a very different approach in mind. Nevertheless, I hope this helps.

:slight_smile:

Thanks for your reply.

I know that it is possible to build mazes manually, either in Godot itself or using third-party tools. And while Blender is great (I totally agree with you here) it was not made for building mazes :-). Your approach is definitely possible and suitable, but I’m looking in a different direction. Anyway, thanks again for your reply.

As I said in the starting post, I do not want to build my level manually.I already have code that produces dungeon “map” and what I need now is to build actual environment based on this map. Moreover, I have testing code that actually does it by placing cubes/walls where needed. However, as I said, I’m not sure whether this is the best approach as from my understanding there might be some issues.

I also have a Maze Generator Python script for Blender, which does a fine enough job, including texturing. Could that be useful..? Here’s an example of a five-level maze, adapted to have stairways between the Levels…

I can’t remember who created the script (I’d have to look it up…), but it’s quite easy to compose and customise.

Both are valid choices, each with pros and cons. In both you have problematic “edge” cases.
With blocks on solid voxels it’s easier to generate, and with “inside out”, where you build in the walls and floors in the empty spaces, it’s a lot more modeling of special parts. In the inside out you’ll lose some space, so corridors and rooms are a little bit smaller than the grid cells themselves.
Blocks on voxels can be limited in that every voxel is one material or type of wall.
You can build all possible combinations, but that will get annoying fast.

In a current project I have the natural stone as the voxel blocks and on top of them the inside out walls, floors and ceiling as single elements.


I use columns to hide problematic edges.

Maybe “outside in” is the better term than “inside out”.
In many cases you may need more than one GridMap. And GridMaps are so limited that they can only hold the mesh and collision shape. No other functionality or lights etc. So they are only a part of the complete logic to build a dungeon.