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
-1
Question by Captain_Dando · Jan 02, 2014 at 01:07 PM · terrainperlin noise

How can I generate terrain as integers using perlin noise?

Hi everyone. I've been working on a game using text to instantiate sprites in the game world. so far, I've been manually typing out each number myself, but now I'd like to learn how to procedurally generate terrain and from what I gather perlin noise is the way to go.

The way I've done it so far, I would have a list of arrays with values like this;

 00001010000000000000000000000000000000000000000000
 00000000000000010000000000000000000000000000000000
 00000000001000000000010100000000000000000000000000
 00000000000010000101111111100000011100110100000000
 00000000000011101111111111111110111111111111111000
 0000000011100111111111111111001111111111111111100
 00000000000010001111111111000001111111111111111100
 00001100110001111111111111100011111111111111110110
 00011111100000111111111010011111111111111110000000
 00000011110111111111110111111111111111111000000000
 00000001111111111100000011111111111011010000000000
 00000000011111111000001111111111101001000000000000
 00000000000100100000000110111110011000000000000000
 00000000000000000000000110010000000000000000000000
 00000000000000000000000000000000011000000000000000

where the 0s would be sea and the 1s would be land. each row is an array, and it can be referenced in a loop, so each block is created one after another based on it's number.

From what I've seen so far, it seems like Mathf.PerlinNoise only returns a float, how could I full my arrays with the values?

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

1 Reply

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

Answer by HappyMoo · Jan 02, 2014 at 02:34 PM

 int mapheight = 15:
 int mapwidth = 30;
 
 Vector2 shift = new Vector2(0,0); // play with this to shift map around
 float zoom = 0.1; // play with this to zoom into the noise field
 
 for(int x = 0; x < mapwidth; x++)
 for(int y = 0; y < mapheight; y++)
 {
   Vector2 pos = zoom * (new Vector2(x,y)) + shift;
   float noise = Mathf.PerlinNoise(pos.x, pos.y);
   if (noise<0.5f) map[x,y] = 0; // water
   else if (noise<0.6f) map[x,y] = 2; // sand
   else if (noise<0.9f) map[x,y] = 1; // land
   else map[x,y] = 3; // mountain
 
 }
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

19 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

Related Questions

Add perlin noise to blocky terrain 0 Answers

2d Top-Down Perlin noise map using Mathf.PerlinNoise 3 Answers

how do i procedurally generated perlin noise infinitely c# 0 Answers

How to use Perlin Noise to generate terrain tiles? 3 Answers

Perlin Noise for 3d Voxel Terrain 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