Max number of Gameobjects (5000?)

I made a simple minecraft clone but I have to delete blocks to instantiate more once I get to roughly 500-800 blocks. Each block has 6 sides (obviously) and one parent object.

Is there a limit for Unity free, or a setting anywhere to change?

Making every block a separate GameObject is extremely inefficient; the standard way is to create mesh chunks that each contain many blocks. There are plenty of topics about this (even code) you can find if you do a search.


I’ve read somewhere that yes, there is a limit.
Someone has tried to generate a grid of tiles of 128*128 GameObject and Unity crashed rightafter.
He replaced his GameObject by ScriptableObject and he was able to generate tremendously more.
But these types don’t have the same purpose.

Here is the link to the post:

the main reason I think why multiple game objects for blocks doesn’t work so well is because…

YOU PROBABLY HAVE 1 mesh per game object…

Meshes are terribly more complex then your average class.

  • Stuff I’ve learned about meshes.
  • A single mesh has a vertex/triangle limit of 65k(I forget which is it actually is since rarely hit the error anymore… I code not to hit it anymore.
  • Sub meshes from what I’ve read take up as much memory allocation as their parent mesh.(I’m sticking with not using the built in sub meshes.)
  • generating meshes and assigning code run pretty fast but they are long loops that when many are running at the same time will tend to lock up the cpu a bit.(This is where multi-threading helps.)
  • The more meshes you have visible the more draw calls/gpu cycles are used to render the screen.
  • Some shaders greatly improve/deprove the rendering of your meshes. FPS wise and drawcall/gpu cycles
  • Generating Tangents for a mesh at run time can be rather time consuming.(I’m working on speeding this up)

I am thinking about using game objects just for updating data and not rendering.

The correct answer is to use prefab chunk objects. The interaction can get rather complex between the chunks and their parent object.

The parent would have an array of the chunks. [chunkX,chunkY,chunkZ]
The parent would also have an array of bytes [x,y,z] bytes would indicate the type of block.

Just about all interactions with the voxel worlds rely on these two data sets to transform your word.

The chunk object then monitors these values and recreates the mesh for the area based on these values.

I think its called “Culling” which is where you determine if specific sides of the “voxel” or cube are visible. And then only create triangles in the mesh for these visible sides.

Then there’s marching cubes which is another story…