- Home /
Procedural terrain generation ?
I've been learning about peling noise for a couple of day's now and i'm trying to create proceduraly generated terrain made out of blocks. In my script i'm trying to generate blocks in all directions but with a different y position (wicth uses simplex noise to calculate it). But I have incountered a problem. When the terrain generates it creates weird formations and the blocks are placed not by 1 unit apart but by 1.4 wicth makes it look uneven. Could someone please help me figure out how to make my terrain look natural? Here's my script:
using UnityEngine;
public class NoiseTest : MonoBehaviour { public Transform grass;
public int terrain_size;
public int terrain_hight;
public bool forming_terrain = true;
private void Start() // Use this for initialization
{
for (int x = 0; x <= 10; x++){
for (int z = 0; z <= 10; z++){
for (int y = 0; y <= 1; y++){
if(forming_terrain){
//float groundHeight = PerlinSimplexNoise.noise(x*0.001f, z*0.001f, y*0.001f)*64.0f;
//float groundHeight = PerlinSimplexNoise.noise(x, z, y)* 5.0f;
float groundHeight = PerlinSimplexNoise.noise(x, y, z)*1.0f;
//groundHeight += PerlinSimplexNoise.noise(x*2.0f, z*2.0f, y*2.0f)*2.0f;
//Vector3 random_new_position = new Vector3(x, groundHeight, z);
//clone = Instantiate(grass, random_new_position, Quaternion.identity);
Instantiate(grass, new Vector3(x, groundHeight, z), Quaternion.identity);
}
}
}
}
}
private void Update() // Update is called once per frame
{
}
}
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Drunkard Walk Algorithm C# Question 0 Answers
2D Procedural Terrain Generation 1 Answer
How to procedural generation 0 Answers
Procedural Terrain Generation on a Map the Scale of the Milky Way 2 Answers