Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by cj31387 · Jun 01, 2012 at 10:47 AM · randomworldgenerated

Randomly Generated Dungeons?

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Victov · Jun 01, 2012 at 03:12 PM

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 it

then 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...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Victov · Jun 01, 2012 at 01:42 PM

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:

  1. Corner piece

  2. Straight piece

  3. T-junction

  4. Dead end

  5. Dead end with loot

  6. 4-way junction

  7. 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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image shadowriffe · Jun 01, 2012 at 02:02 PM 1
Share

http://en.wikipedia.org/wiki/$$anonymous$$aze_generation_algorithm

Take a look at this algorithm too. It generates a maze randomly. $$anonymous$$aybe try doing a maze game first and then elaborate on the concept bringing it closer to the dungeon crawler you want it to be.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

pre generated world 0 Answers

accessing variables from nearby gameobjects (Prim's Algorithm) 2 Answers

Minecraft strater package in JS 0 Answers

How can i make an infinite level? 4 Answers

Generate minecraft alike terrain 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges