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 ExtremePowers · Aug 05, 2014 at 11:06 PM · perlin noiseinfinite terrainchunk

Tileable perlin noise terrain

I have been trying to make an infinite terrain over the last couple of weeks but I can't make it work, here is my current code:

  function GenerateTile(nw : int, nh : int) {
     if (GameObject.Find("Chunk "+nw+","+nh)) { 
         return;
     }
          
     var freq : float = Frequency;
     var td = new TerrainData();
     td.heightmapResolution = 513;
     td.size = new Vector3(500,200,500);
 
     var ChunkPosX : float = td.size.x * nw;
     var ChunkPosY : float = td.size.z * nh;
 
     var t = Terrain.CreateTerrainGameObject(td);
     var hw : float = Terrain.activeTerrain.terrainData.heightmapWidth;
     var hh : float = Terrain.activeTerrain.terrainData.heightmapHeight;
     var heights = new float[hw, hh];
     for (var x = 0; x < hw; x++) {
         for (var y = 0; y < hh; y++) {
             //           World Pos Divided by heightmap height
             var xCoord = ((ChunkPosX + x) / (Mathf.PI * scale));
             var yCoord = ((ChunkPosY + y) / (Mathf.PI * scale));
             if (x == 0 && y == 0) {
                 Debug.Log(xCoord);
                 Debug.Log(yCoord);
             }
             heights[x,y] = Mathf.PerlinNoise(xCoord, yCoord);
         }
     }
     Terrain.activeTerrain.terrainData.SetHeights(0,0,heights);
     t.transform.position = new Vector3(ChunkPosX, 0,ChunkPosY);
     t.name = "Chunk "+nw+","+nh;
 }




Comment
Add comment · Show 15
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 rutter · Aug 05, 2014 at 09:38 PM 0
Share

What's not working about it? The more specific you are, the easier it will be to help.

avatar image ExtremePowers · Aug 05, 2014 at 09:43 PM 0
Share

When I try to generate a tile it is the same every time, even though the nw and nh is changing.

avatar image Sessional · Aug 06, 2014 at 10:54 PM 0
Share

When generating random terrain if you don't change the seed before you generate it, you will always have the same randoms come out in the same order - thus you'll end up with the same terrain.

Generate yourself a seed based upon system time or something?

avatar image ExtremePowers · Aug 07, 2014 at 12:10 AM 0
Share

I meant that every chunk will look the same, They all have the same hills and such. Example: if I generate chunk (1,0) and (0,0) They look exactly the same. Same with (23, 57) and (53, 89) They always look the same.

avatar image Sessional · Aug 07, 2014 at 12:15 AM 0
Share

Perlin values are between -1 and +1, are you multipying your perlin call by a scalar to actually add some variation? They will all look extremely close in height otherwise.

edit: I lied: in unity they are between 0 and 1.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by knoakes · Aug 08, 2018 at 04:21 PM

Does this video help you... https://www.youtube.com/watch?v=dycHQFEz8VI&t=1176s

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

7 People are following this question.

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

Related Questions

Tiling problem with Perlin generated terrain chunks 1 Answer

How to generate infinite cube world / minecraft terrain with perlin noise? 1 Answer

Minecraft clone - On iPhone!? 1 Answer

Make a high poly count plane with code 0 Answers

Mathf.PerlinNoise not returning in Waves 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