1
\$\begingroup\$

I'm trying to prototype a little 3D dungeon crawler. That is, the same system as any rogue-like : A map with little rooms, linked by hallways.

But in 3D. The world is still in blocks, but I can go up and down. This game is a nice exemple of what I want. I still want the world to be mostly flat (for exemple every room could be at the same height) but I need some little up-and-downs in the rooms, or the hallways between them.

I already tried 2D dungeon generation with no precise algorithm (just by myself) but I think this time it would be best to have some nice algorithm and a good workflow about it.

So I need help about this :

  • A nice 3D generation
  • What data structures should I use to store my levels ?
  • How should I then create it ? I'm on Unity, and for now I am associating an enum to prefabs for each type of map blocks, and then I instantiate every case. Is it a good way of doing this ?
\$\endgroup\$
6
  • \$\begingroup\$ Have you tried anything? Just use perlin noise to create a heightmap and use that to make the terrain. \$\endgroup\$
    – pangaea
    Commented May 19, 2013 at 13:05
  • \$\begingroup\$ The problem with Perlin noise is that it is meant for a terrain, and in my case it is little rooms and hallways, which means most of the map is actually void... Not sure Perlin Noise would give good results. And for what I have tried, I have a room generator on Unity which places blocks on a 3D array and then instantiate floor/walls. But generating a nice pack of rooms linked to each others is harder. \$\endgroup\$
    – nialna2
    Commented May 19, 2013 at 13:10
  • 2
    \$\begingroup\$ possible duplicate of What are some ideal algorithms for Rogue-like 2D dungeon generation? \$\endgroup\$
    – msell
    Commented May 19, 2013 at 13:58
  • 3
    \$\begingroup\$ As with many things, there is often no such thing as the best way to do something, it always depends on so many different things, that you have to simply leverage the context of your game to make an educated decision about which approach to take. This sounds like a fun problem, a great opportunity to try your best, potentially fail, and either way learn a heck of a lot from the experience :) \$\endgroup\$
    – Evan
    Commented May 19, 2013 at 14:00
  • \$\begingroup\$ procedural content generation wiki. I'm just saying =) \$\endgroup\$ Commented May 19, 2013 at 17:14

1 Answer 1

1
\$\begingroup\$

If you already have code that generates rooms connected with hallways in 2D simply update your code to do this:

Each generated room gets a random height (pretty obvious right?). I would try with picking from a list of predefined height values or simply pick a random value from a good interval. Then proceed as usual - connect the rooms with hallways, but this time you will have to account for the height difference.

Connecting the rooms should be easy - if you went with the predefined heights approach it will be even easier. What I would do would simply build the hallway from one room to another, each step (cell of your map) getting as close to the target elevation as possible.

So if room A has exit at (0,0,0) and room B entrance at (2,4,3) then each step of building the hallway will place the next block as close to the target as possible:

Step 1: (0,0,0) Step 2: (1,1,1) Step 3: (2,2,2) Step 4: (2,3,3) Step 5: (2,4,3)

This is the simplest approach and the easiest to do, but might not get the prettiest results. Try experimenting to see what works best for you.

\$\endgroup\$
1
  • \$\begingroup\$ That´s what I'm considering now, but For hallways that cross each other, there could be some height problems... But I'm developing this solution \$\endgroup\$
    – nialna2
    Commented May 20, 2013 at 9:14

Not the answer you're looking for? Browse other questions tagged .