- Home /
This question was
closed Apr 20, 2013 at 09:54 PM by
Eric5h5 for the following reason:
Duplicate Question
Perfomance Issue With Minecraft Clone.
Trying to make a basic minecraft clone, or a cube world. To do this i am using a perlin noise 2d function to set the height of the individual cubes, works great but i have a giant problem with the framerate, if i make the world any bigger than 100x100 my framerates drops trough the roof. It seems like the gameobjects is a massive resource hog. How can i fix or improve this. Thank you! :)
Script:
void PerlinFunction ()
{
PerlinNoise perlin = new PerlinNoise(Random.Range(0,800));//Perlin function seed
for (int x = 0 ; x <100; x++)//Size of the world(x,z)
{
for (int z = 0 ; z <100; z++)//Size of the world(z)
{
int yvalue = (int)perlin.FractalNoise2D(x,z,1,48,16);//Gets a random pelin value,used as the y size
GameObject cube = Instantiate(prefabgrass, new Vector3(x, yvalue, z), Quaternion.identity) as GameObject;//Instantiates a new cube at location x,PERLINNOISE,z
}
}
}
Looks like this:
terrain.jpg
(309.5 kB)
Comment
most existing unity $$anonymous$$ecraft questions answer this already
Please do a search; this has been discussed to death. In short, don't use separate GameObjects for each voxel, that's ridiculously inefficient.