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 Vortex_404 · Dec 27, 2013 at 12:59 PM · terrainprocedural generationsidescrollerblock

How to generate Blocks like Terraria (2D)

Hey guys, I'm making a Terraria + Castlevania SotN mix, got Characterstats, Inventory, etc. done.

When reaching the point where I have to create the world the player will be wandering, I just made a quick and dirty solution. I took the PerlinNoise, put in a 128x128 Texture to show me the output (this grey noise). Checked the output values, saw there is always something bewtween 0.0f and 0.6f (with my current settings).

I created 9 Blocks for testing, and placed the blocks depending on the Noisevalue..

0.0f - 0.1f dirt 0.1f - 0.2f stone

etc...

My problem is, I don't know how to modify the noise correctly to create biomes with it. I found barely anything that could help me on my topic, so I hope you could give me at least a nice hint.

alt text

Have a nice day

unity forum.png (389.5 kB)
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

4 Replies

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by sparkzbarca · Dec 27, 2013 at 01:50 PM

i don't claim to know how its normally done but the way i'd do it.

Define each bio as a class

have in it a list of blocks which that bio can choose from to spawn

assign each block a random chance of being selected

so for example

 DesertBio
 {
 list<blocks> BlocksSpawnable;
 
 BlocksSpawnable.add(DesertTile);
 BlocksSpawnable.add(WaterTile); //small chance of an oasis
 BlocksSpawnable[1].getComponent<BlockScript>().SpawnChance = 80;
 BlocksSpawnable[0].getComponent<BlockScript>().SpawnChance = 20;
 
 //create bio returns a 2 dimensional list of blocks to spawn
 blocks[,] CreateBio(int Length, int Width)
 {
 blocks[,] BlocksToSpawn = new blocks[Length, Width];
 
 // at this point you can start specializing
 //for example if height is  != 0 (not at ground level) remove snowy ground cover blocks from 
 //possible spawn list and redistribute there spawn chance.
 
 //check all neighboring blocks and if a water block exists chance to spawn water goes to 75%
 //so for example
 
 for(int X = currentX - 1 ;X <= currentX + 1; X++
 {
 for (int Y = currentY - 1; X <= currentY + 1; Y++
 {
    if(Blocks[X,Y].tag == "water")
       //Modify spawn chance
 }
 }
 
 //now that you've done all the modifications you just generate a number and compare to figure out which block to spawn.
 
 
 
 }


Hope this helps, post if you need more help

Comment
Add comment · Show 3 · 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 Vortex_404 · Dec 27, 2013 at 02:13 PM 0
Share

I'm gonna try this and tell you how it worked, but it looks pretty good for now

avatar image sparkzbarca · Dec 27, 2013 at 07:14 PM 0
Share

well you also need to implement a method to randomly create biomes in the same way by randomly designating chunks of the world as biomes and then using special rules to deter$$anonymous$$e the next biome so that you can have randomly sized biomes and make sure there isnt a desert next to a snowland.

avatar image Vortex_404 · Dec 28, 2013 at 10:04 PM 0
Share

Hey, thanks a lot for the help, but I came upon this [[Tutorial] Procedural meshes and voxel.] [1]

And it looks pretty easy actually.

[1]: http://forum.unity3d.com/threads/198651-Tutorial-Procedural-meshes-and-voxel-terrain-C

avatar image
0

Answer by alteveer · Mar 02, 2014 at 12:25 AM

This guy is a genius:

http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/

The code is in AS3, so easy to port to JS, I am using this to make island shapes and it works very well. The key is to hook the threshold, etc variables up to public variables so you can tweak them while the game is running.

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
0

Answer by Bren0831 · Dec 18, 2016 at 06:32 PM

Try using Perlin Noise as a function

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
0

Answer by GrKl · Dec 19, 2016 at 07:30 AM

When doing something similar in 3D, I used different Perlin Noise calls with different parameters to set some basic values:

Call one gave me the height of the terrain Call two gave me the humidity of the terrain Call three gave the temperature.

Earth biomes actually work basically on these 3 data.

You can now set biomes depending on the above results. Google Image search "biome graph". This should help with the idea.

You than specify how each biome should behave

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

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

22 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

Related Questions

Block Terrain Generator 5 Answers

How Do I Properly Generate Biomes In Infinite Terrain? 1 Answer

subdivide a plane? or switch to a terrain (procedural voronoi diagram) 1 Answer

Navmesh on Terrain cracked 0 Answers

How to make a block terrain by hand? 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