







Hello everyone following the voxel tutorial, it's been a long time since an update. In this time I've written a new updated tutorial on voxel terrain that supports infinite terrain and saving/loading of chunks. Try it out on my new site: AlexStv.com





void GenTerrain(){ blocks=new byte[96,128]; for(int px=0;px<blocks.GetLength(0);px++){ for(int py=0;py<blocks.GetLength(1);py++){ } } }

int Noise (int x, int y, float scale, float mag, float exp){ return (int) (Mathf.Pow ((Mathf.PerlinNoise(x/scale,y/scale)*mag),(exp) )); }

void GenTerrain(){ blocks=new byte[96,128]; for(int px=0;px<blocks.GetLength(0);px++){ int stone= Noise(px,0, 80,15,1); stone+= Noise(px,0, 50,30,1); stone+= Noise(px,0, 10,10,1); stone+=75; int dirt = Noise(px,0, 100,35,1); dirt+= Noise(px,0, 50,30,1); dirt+=75; for(int py=0;py<blocks.GetLength(1);py++){ if(py<stone){ blocks[px, py]=1; } else if(py<dirt) { blocks[px,py]=2; } } } }

int stone= Noise(px,0, 80,15,1);

stone+= Noise(px,0, 50,30,1);

stone+= Noise(px,0, 10,10,1);

Stone and dirt noise.

void GenTerrain(){ blocks=new byte[96,128]; for(int px=0;px<blocks.GetLength(0);px++){ int stone= Noise(px,0, 80,15,1); stone+= Noise(px,0, 50,30,1); stone+= Noise(px,0, 10,10,1); stone+=75; print(stone); int dirt = Noise(px,0, 100f,35,1); dirt+= Noise(px,100, 50,30,1); dirt+=75; for(int py=0;py<blocks.GetLength(1);py++){ if(py<stone){ blocks[px, py]=1; //The next three lines make dirt spots in random places if(Noise(px,py,12,16,1)>10){ blocks[px,py]=2; } //The next three lines remove dirt and rock to make caves in certain places if(Noise(px,py*2,16,14,1)>10){ //Caves blocks[px,py]=0; } } else if(py<dirt) { blocks[px,py]=2; } } } }

Now you should get caves and dirt spots.