Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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 ?
share|improve this question

closed as not a real question by msell, Byte56, Anko, Patrick Hughes, bummzack May 21 '13 at 9:50

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Have you tried anything? Just use perlin noise to create a heightmap and use that to make the terrain. –  pangaea May 19 '13 at 13:05
    
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. –  Malharhak May 19 '13 at 13:10
2  
possible duplicate of What are some ideal algorithms for Rogue-like 2D dungeon generation? –  msell May 19 '13 at 13:58
3  
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 :) –  Evan May 19 '13 at 14:00
    
procedural content generation wiki. I'm just saying =) –  Patrick Hughes May 19 '13 at 17:14

1 Answer 1

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.

share|improve this answer
    
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 –  Malharhak May 20 '13 at 9:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.