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 sxriter · Feb 01, 2013 at 09:05 PM · noisecubesperlinperlinnoise

Help Perlin Noise for Cubes?

I got this code from the wiki unity3d, i want blocks, no terrain. I don't understand PerlinNoise but is the only way to create random cubes like minecraft. I don't know other mode to make random cubes, help please or a simple code in C# or Js for cubes. Sorry bad english i'm from Argentina.

 using UnityEditor;
 using UnityEngine;
 using System.Collections;
  
 public class TerrainPerlinNoise : ScriptableWizard {
  
     public float Tiling = 10.0f;
  
     [MenuItem("Terrain/Generate from Perlin Noise")]
     public static void CreateWizard(MenuCommand command)
     {
         ScriptableWizard.DisplayWizard("Perlin Noise Generation Wizard", typeof(TerrainPerlinNoise));
     }
  
     void OnWizardUpdate()
     {
         helpString = "This small generation tool allows you to generate perlin noise for your terrain.";
     }
  
     void OnWizardCreate()
     {
         GameObject obj = Selection.activeGameObject;
  
         if (obj.GetComponent<Terrain>())
         {
             GenerateHeights(obj.GetComponent<Terrain>(), Tiling);
         }
     }
  
     public void GenerateHeights(Terrain terrain, float tileSize)
     {
         float[,] heights = new float[terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight];
  
         for (int i = 0; i < terrain.terrainData.heightmapWidth; i++)
         {
             for (int k = 0; k < terrain.terrainData.heightmapHeight; k++)
             {
                 heights[i, k] = Mathf.PerlinNoise(((float)i / (float)terrain.terrainData.heightmapWidth) * tileSize, ((float)k / (float)terrain.terrainData.heightmapHeight) * tileSize)/10.0f;
             }
         }
  
         terrain.terrainData.SetHeights(0, 0, heights);
     }
 }
Comment
Add comment · Show 1
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 Wolfram · Feb 01, 2013 at 09:45 PM 0
Share

Sorry, but this site is for specific questions, and not for "I found this script and I want to make it do something else, who can change it for me?".

1 Reply

· Add your reply
  • Sort: 
avatar image
5

Answer by MountDoomTeam · Feb 01, 2013 at 09:17 PM

alt textHello, here is a page that shows you what the Perlin noise is, http://answers.unity3d.com/questions/188721/creating-perlin-noise.html#answer-383517 it generates lots of little bumps like an irregular sinus. What you can do, is instantiate 100 blocks along the X axis, 100 blocks along the Y axis, keep their width and length the same but modify their height with Perlin noise function. to make a really nice bunch of hills, if you multiply 2 Perlin noise functions against each other, then they will make strange irregular hills, because 1x1 equals 1 and 0x0 equals 0, imagine multiplying 2 of the wiggles like in the picture on the link. It becomes a 3d Mountain scape. I would do you some code that I'm a bit tired right now!

 private var rot : Quaternion;
 rot.eulerAngles = Vector3(0, 0, 0);
 var terraincube: GameObject;
 
 function Start (){
 for (var px:float = 0; px < 100; px ++) {
     for (var py:float = 0; py< 100; py ++) {
  
 var Perlin1 = Mathf.PerlinNoise(px/30, 76);
 var Perlin2 = Mathf.PerlinNoise(py/30, 22);
 Instantiate(terraincube, Vector3(py-50, Perlin1*40*Perlin2, px-50), rot);
 
  
 }
  
 }
 }    


cubreterrain.png (115.5 kB)
Comment
Add comment · Show 4 · 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 MountDoomTeam · Feb 01, 2013 at 09:50 PM 1
Share

/30 is closeness of hills, 40 is height of hills.

avatar image sxriter · Feb 01, 2013 at 10:30 PM 1
Share

thank you men! it works

avatar image Wolfram · Feb 01, 2013 at 10:35 PM 1
Share

Then please mark his answer as "accepted", and don't post comments in the "Your answer" field, use the "add new comment" button ins$$anonymous$$d.

avatar image MountDoomTeam · Feb 04, 2013 at 05:41 PM 2
Share

:) http://forum.unity3d.com/threads/83316-3D-Perlin-Noise-in-progress-(terrain-generation-etc.)

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

11 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

Related Questions

What's wrong with this code? Perlin Noise 0 Answers

Perlin Noise Issue 0 Answers

Perlin noise tutorials ? 2 Answers

Perlin Noise Plane Manipulation 1 Answer

Basics of Perlin Noise? 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