I have a Unity project in which I have the necessary code to create a texture anywhere from 2x2 to 512x512 and fill it with perlin noise. I am using this texture to populate a map of blocks (think minecraft) .
The map generates correctly, but Unity starts lagging with that many cubes?
This is an image of the generated map, 256x256.
Any leads in the right direction would be appreciated, I’m just stumped on how to get passed this.
This is the method to populate the map
private void GenerateMap ()
{
for (int x = 0; x < creator.resolution; x++) {
for (int z = 0; z < creator.resolution; z++) {
Object newCube = Instantiate (cube, new Vector3(x, Mathf.Round (texture.GetPixel (x, z).b * 10), z), Quaternion.identity);
newCube.name = "Cube: " + x + ", " + z;
}
}
Debug.Log ("Finished generating world");
}