ive have been working on a voxel game, and have decided to tackle word generation using perlin noise, i managed to create simple terrain easily
but i wanted to create more interesting cube world sytled terrain
ive been trying for 2 hours and have made no progress (and yes i have seen all the other posts)
so i decided to ask the internet
Heres the code i used to create the simple terrain
void Start () {
float posX = transform.position.x;
float posZ = transform.position.z;
for (int y = 0; y < chunkY; y++) {
for (int z = 0; z < chunkZ; z++) {
for (int x = 0; x < chunkX; x++) {
//Terrain algorithm
float flatNoise = Mathf.Round (Mathf.PerlinNoise ((transform.position.x + x) * Flatscale, (transform.position.z + z) * Flatscale ) * 10);
float height = flatNoise;
Vector3 pos = new Vector3 (posX, height, posZ);
GameObject newBlock = Instantiate (block, pos, Quaternion.identity) as GameObject;
newBlock.transform.parent = this.transform;
posX += 1;
}
posX = transform.position.x;
posZ += 1;
}
posX = transform.position.x;
posZ = transform.position.z;
}
}
Note: chunk x, y and z are just sizes