- Home /
Best way to smash a Cube made out of 100x100x100 cubes.
I need to create a big 100x100x100 cube made out of smaller 1x1x1 cubes and then smash it into peaces.
I understand, that I only need to create as much mini cubes as I need to cover the surface, but I don't know what is the best method to adding additional cubes after the surface ones are destroyed/removed.
Answer by robertbu · Oct 05, 2014 at 09:18 PM
The mega-cube you describe would have one million cubes. There is no way Unity will run reasonably (at all???) with a million game objects. Just the sides will have around 60,000 cubes. If the cubes have no scripts and a light-weight shader, you might be able to get reasonable performance out of 60,000 cubes on a desktop.
If you really needs this, search out references on Unity Answers and elsewhere to Voxels and Minecraft. The concept is building multiple cubes out of a single mesh. Even then you'd need 250+ meshes each with 4K of cubes in order to get your million cubes.
I did mention in my problem that : "I only need to create as much $$anonymous$$i cubes as I need to cover the surface". So ins$$anonymous$$d of having a million cubes i would only have (100 + 90 + 90 + 90 + 90 +60? = 500 cubes). $$anonymous$$y question was/is what is the best way to add additional cubes after the surface ones are removed
You could use a particle effect, make a spritesheet with several frames of a rotating cube.
This thread used to be some sort of reference to people trying that.
Each side will be 100 x 100 cubes (give or take), so just doing the sides is around 50,000 cubes, not 500. For the explosion, you are going to have to have the surface cubes plus at least some percentage of the interior cubes. Using 50,000 is problematic. Using 150,000 or 250,000 like you'll need for a good looking explosion is unusable. I've run some Unity apps using 50,000 game objects on my desktop. They were non-moving objects with shared material and batched, and the app ran vary slowly. If you don't believe me, 15 $$anonymous$$utes of coding should allow you to build the surface cubes, and you can test it yourself.
If you really want this to work, then you are going to have to figure out alternate solutions. $$anonymous$$aybe a ParticleSystem. $$anonymous$$aybe Voxles. $$anonymous$$aybe some sort of shader magic.
Answer by Cherno · Oct 07, 2014 at 01:05 PM
You create teh mesh by code, like Minecraft clones do. RobertBu already mentioned Voxels and MC. So If the surface cubes are recmoved, you would recreate the mesh(es) to make the next layer.
Your answer
Follow this Question
Related Questions
Multi Resolution 1 Answer
Why is the CPU usage so high? 1 Answer
What Resolution to draw sprites for Mobile game?? 1 Answer
Shader Based Mesh Generation 0 Answers
What is the expected behaviour of Dynamic Batching? 2 Answers