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 /
avatar image
0
Question by EddieHittler · Sep 30, 2015 at 10:07 AM · terrain genperlinnoise

Help with perlin noise terran generation script

So, I've stuck on this issue for a couple of days and to save what little of my hair I have left, I'll ask you good people for some help.

I have some code that creates some terrain in a 25x25 grid of cubes based of perlin noise. it also creates a flat bottom area of the same size. What I want to do is fill the area between the top terrain and the bottom.

Here's the code for the terrain Gen.

 void Start()
     {
         // Creation of terrain
         for (var X = 0; X < Size; X++)
         {
             for (var Z = 0; Z < Size; Z++)
             {
                     var TheLandCreator = Instantiate(ThePlatform, new Vector3(X, 0, Z), Quaternion.identity) as GameObject;
                     TheLandCreator.transform.parent = transform;
 
                     Instantiate(Bottom, new Vector3(X, -5, Z), Quaternion.identity);
                     
                     Red = 0.14f;
                     Green = -0.22f;
                     Blue = -0.51f;
                     Scale = Random.Range(6f, 14f);
                     ScaleModifier = Random.Range(-5f, 14f);
             }
         }
      }       

Here's an image of what this creates.

alt text

I've Tried this in a variety of ways. The last way I tried was attaching a script to the terrain cube which instantiated more cubes down to the bottom, until it collided with the bottom layer. Unfortunately this script crashes Unity? Here's the script.. I'm only showing it to see if I was on the right track or whether I'm over thinking the whole thing.

 using UnityEngine;
 using System.Collections;
 
 public class TerrainFill : MonoBehaviour {
     public Transform Cube;
     public GameObject CubeFill;
     public bool HitBottom = false;
 
     // I want to spawn a cube under the terrain until it hits the bottom layer.
 
     void Start ()
     {
         StartSpawningTheFillPlease();
     }
 
 
     void StartSpawningTheFillPlease()
     {
         for (var Y = 0; HitBottom == false; Y++)
         {
             Instantiate(CubeFill, new Vector3(0, Y-1, 0), Quaternion.identity);            
         }
     }
 
     void OnTriggerEnter(Collider other)
     {
         HitBottom = true;
     }
 }

 

Any help anyone can give is greatly appreciated. Many thanks Eddie.

whatihavesofar.png (200.8 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MerryAce123 · Sep 30, 2015 at 11:05 AM

The reason why it crashes is because if you fill the area between the bottom and the top you create too much objects, probably more than unity can handle. I know what you are trying to achieve but this is very inefficient way to make your perlin terrain. The way how you SHOULD do it is by making the whole area with only one object which is called a chunk. However this requires at least a basic knowledge of procedural mesh building. Check youtube for some tutorials there are plenty of them... https://www.youtube.com/watch?v=c9roVJKl4GU

Comment
Add comment · Show 1 · 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 EddieHittler · Sep 30, 2015 at 12:48 PM 0
Share

Thanks @$$anonymous$$erryAce123 I was thinking that could be the issue.. I'm off to learn about procedural mesh building. :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Is this reading the full range of Perlin Noise? 1 Answer

perlin noise terrain is spikey 0 Answers

I need a 2d texture of a corn plant? 0 Answers

Gradient blending textures from different vertex points 0 Answers

Is there a Unity tutorial that shows rpg terrain for pro 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