• 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 jessee03 · Mar 24, 2012 at 09:03 PM · arrays

Endless random array

I've never really messed with arrays too much before and was wondering what would be the best way in going about generating random endless tile maps. This will be a 2d game and will randomly generate floor and wall tiles, all the wall tiles must not block off the player from going through to the north, south east or west parts or get too crowded so the player can continue to move in any direction and have a new set of tiles be generated. Also it needs to have some way to remember everything in the array to be able too go back through any part of the game. Everything in the array should be saved and loaded as well.

Comment
Add comment · Show 5
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 Befall · Mar 24, 2012 at 09:46 PM 0
Share

I don't have an exact specific answer, but there are definitely a lot of ways to go about it. Having recently made my first procedurally-generated seed-based game, I have my head wrapped around it a bit.

So, I think you may want to end up using semi-random generation, where it generates tiles in a certain area around the player based on a single seed. That way, when you return, this algorithm, using the constant seed, will generate the same exact configuration of tiles.

This means you don't need to physically save the tiles, as they generate the same way every time.

avatar image jessee03 · Mar 24, 2012 at 10:07 PM 0
Share

Oh I wanted everything to genertate randomly. Like make it so the player is able to walk to each area still without being blocked off. So the hard part about wrapping my $$anonymous$$d around the concept is creating tile maps that branch off of each other. So lets say you have a tileset that's 8x8. Then you want it so when you start traveling to a new area it's already been randomly generated. I also want to make it so the player is never cut off from an area or boxed in anywhere so they can constantly walk. Almost like a random endless maze generator.

avatar image Befall · Mar 24, 2012 at 10:11 PM 0
Share

There's no "simple" way to do that, really. It's just surfing around the web to find algorithms and code that could aid you in your quest. Essentially, though, it sounds like every time you generate a new set of tiles, you'll need to do basic pathfinding to make sure the player has room to move and path to follow.

And, for example, you're at 0,0. You venture to 100,100 and return to 0,0. Do you want the tiles at 0,0 to be EXACTLY the same, or different? If you want to be able to come back to the same rooms after they've "despawned", you'll need to use some sort of seed system. Otherwise, it sounds like the player will just be moving through endless, ever-changing roomsets?

avatar image jessee03 · Mar 24, 2012 at 11:02 PM 0
Share

Oh I get what your saying. yes once it's been randomly generated that tileset would remain the same. So if you have already adventured to a tile set it will remain the same. I don't like refrencing other games but imagine how $$anonymous$$ecraft works how everything is random but if you come back to a spot it will be the same unless you or someone else altered it.

avatar image Befall · Mar 24, 2012 at 11:05 PM 0
Share

Nah, I followed the same idea with my generation game. The only thing you'll need to do, if you wish to have changes possible on tiles is a specific list of tiles that have been adjusted, and something unique about them (I usually use position). Then, when you load up a new "chunk" of tiles, you check to see if any of them are in the "adjusted" list, and can change them accordingly.

0 Replies

· Add your reply
  • Sort: 

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

transform array in javascript 2 Answers

problem accesing arrays 2 Answers

Multidimensional GameObject Arrays 1 Answer

Create a Word Game like Scrabble in Unity? 0 Answers

Creating an inventory/weapon array and ability to scroll through it 1 Answer


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