I have created this minecraft-ish voxel game where the player can create a voxel map. I have a block prefab (nothing much of the ordinary) - it has a box collider, a texture, and a mesh renderer.
On my code, it just as simple as this:
public void GenerateTerrain() { for(int x = 0; x < mapSizeX; x++) { for(int z = 0; z < mapSizeZ; z++) { GameObject groundBlock = Instantiate(groundBlocks[0], new Vector3(x, transform.position.y, z), Quaternion.identity); groundBlock.transform.parent = transform; } } }
I think this works fine if you put in 32x32. However if the player tries to generate a 128x128 (16k blocks) or greater and tries moving around the map, the game crashes and even shutdowns the computer (i know it's scary).
I tried using the built in occlusion culling, it kinda increased the performance "a bit", however it still crashes.
How can I fix this?
public void GenerateTerrain() { for(int x = 0; x < mapSizeX; x++) { for(int z = 0; z < mapSizeZ; z++) { GameObject groundBlock = Instantiate(groundBlocks[0], new Vector3(x, transform.position.y, z), Quaternion.identity); groundBlock.transform.parent = transform; } } }
I think this works fine if you put in 32x32. However if the player tries to generate a 128x128 (16k blocks) or greater and tries moving around the map, the game crashes and even shutdowns the computer (i know it's scary).
I tried using the built in occlusion culling, it kinda increased the performance "a bit", however it still crashes.
How can I fix this?