# Randomly Generated Dungeons?

 0 Hi, I'm pretty knew to programming and unity, but I was wondering if anyone can link me some reading material on how to randomly generate levels in unity. I eventually want to make a game where you get random missions, then walk into a portal and it takes you to a randomly generated dungeon with a boss at the end and chests loot, and enemies all the way in between. I don't plan on doing this anytime soon but would like to start reading up on it so some links on this subject would be very appreciated. Thanks. more ▼ asked Jun 01 '12 at 10:47 AM cj31387 86 ● 14 ● 25 ● 34 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

2 answers: sort voted first
 0 Try doing the same in 2d first. Level generation can be pretty tough, especially when you're new to programming.You're probably going to want to do this tile-based. Make a grid of like 32x32 trough arrays. In a modelling program make different tiles, corner pieces, walls, etc etc. Then write a program that generates the dungeon and fills those arrays. You surely remember these kind of games from your childhood: Tile based 2d game this is exactly what you're going to want to do in 3d. The pipe would be an open area (where the player can walk) and the white would be walls. Number your different pieces. Like:corner piece - 1,straight piece - 2,dead end - 3,dead end with loot chest - 4,t-junction - 5,well, you get itthen generate the 2dimentional array: ``````int[,] tiles = new int[32,32]; tiles[0] = {1,2,1,2,3,4,1,1,2,4,3,3,1,1,2,2,4,1}; tiles[1] = {2,1,1,2,3,4,2,3,3,2,3,3,1,2,2,2,4,1}; tiles[2] = {1,3,4,2,3,4,1,2,2,3,3,3,4,1,2,2,4,2}; ``````of course you don't want this to be static, you want it to be dynamically generated.Have fun with it... you said you weren't an experienced programmer... more ▼ answered Jun 01 '12 at 03:12 PM Victov 36 ● 1 ● 1 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users
 0 You're gonna want to use tiles. Try making it in 2d first, outside of unity. Since you're not an experienced programmer I really don't think this is gonna work, but here we go:Make different models that fit seamlessly next to each other. A corner piece, a straight piece, a dead end... A bit like this.Give each of your different pieces a unique ID, like this: Corner piece Straight piece T-junction Dead end Dead end with loot 4-way junction You get it by now... Then make a multidimensional array, this example is static, you want to dynamicly randomly generate this. ``````int[,] tiles = new int[32,32]; tiles[0] = {1,2,1,2,3,1,1,2,3,1,1,2,2,3,2,1,2,3,1,3,2,2,3}; tiles[1] = {2,3,1,2,3,3,1,2,3,2,7,2,2,3,2,5,2,3,5,3,5,2,3}; tiles[2] = {3,1,2,2,3,1,4,2,3,5,1,2,3,3,2,1,2,3,1,3,2,4,3}; ``````All the way down to 31, so that you have a 32x32 tile. (you can make it bigger ofcourse, you're only gonna need a better algorithm then). Look up these links for ideas and reading material: here, and take this!this one is not in C# (unity is) but it does explain the basics of making a tile-based game very well. Very last link you're gonna get from me is this one, this is not about generating, nor is it about your type of game, but it has been so useful to me I had to just give you the link. The playlist is too short, there are more videos, just check his channel. more ▼ answered Jun 01 '12 at 01:42 PM Victov 36 ● 1 ● 1 http://en.wikipedia.org/wiki/Maze_generation_algorithmTake a look at this algorithm too. It generates a maze randomly. Maybe try doing a maze game first and then elaborate on the concept bringing it closer to the dungeon crawler you want it to be. Jun 01 '12 at 02:02 PM shadowriffe add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Topics:

x570
x109
x21

asked: Jun 01 '12 at 10:47 AM

Seen: 1457 times

Last Updated: Jun 01 '12 at 03:12 PM