Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by studioAdam · Nov 19, 2016 at 02:18 PM · terrainmesh2d-platformerprocedural

Best way to cycle through different generation settings?

Ok, so I'm messing around making terrain using procedurally generated meshes in a 2D sidescrolling platformer type game. I have made it so that there are different types of terrain that can be generated but I don't change these within the scene, they're there so I can have different scenes with different types of terrain. I currently have three types and I call each one regularLand, sandDunes and mountainLand. Basically, in sandDunes the generated mesh follows a wavey pattern, in mountainLand the mesh constantly slopes downward and then in regularLand I have further sub types. Inside of regularLand I can randomly produce a startIsland, midIsland, endIsland to make one long island piece one piece at a time. There is also a smallIsland which is as it sounds and lastly bridgeTerrain, again as it sounds, just the mesh is really thin here.

The way I have set this up is by creating an enum called MainTerrainType and this includes regularLand, sandDunes and mountainLand. Then I have another enum called RegularLandSubTerrainType which includes startIsland, midIsland, endIsland, smallIsland and bridgeTerrain.

Now, I'm relatively new to Unity and coding and this feels really cumbersome and as if it's really bad coding practise. This is because throughout the rest of my code I need to test what type of terrain the class is currently producing, like I use the midIsland terrain to place a cave type thing, for example:

if(mainTerrainType == MainTerrainType.regularLand && regularLandSubTerrainType == RegularLandSubTerrainType.midIsland) { //Make a cave and place cave prefabs. }

or

if(mainTerrainType == MainTerrainType.regularLand && regularLandSubTerrainType == RegularLandSubTerrainType.startIsland) { //Make startIsland and make the start of the mesh sloped and the end of the mesh flat ready for the next piece. }

Can you see what I mean? What would be a good way to do this better? Also, I let the decision on what terrain to make next up to the script with hardcoded variables. I'd prefer to use public ints to set different variables for different scenes. So at the moment, startIsland can only transition to either midIsland or endIsland. I create a random int between 0 and 100 and say, if the int is <= 20 goto midIsland, if its >= 21 goto endIsland. But to have public ints for all the possible transitions seems like poor code and I'd have a massive list of public ints in the Inspector. I wouldn't mind coding it, but is there a better way?

Thanks in advance.

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

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.

Follow this Question

Answers Answers and Comments

93 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to spawn in loop like snail but in square 0 Answers

Procedural Generation : Grass placement 2 Answers

Road on Low-poly Terrain?? 0 Answers

Diamond Square Algorithm Problems 0 Answers

Triangles for sphere 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