- Home /
Instantiation and Deletion very slow... HELP..
So I am making a game, which you can go on forever, like minecraft but 2d, and im going to use cubes. But the issue with this, is that for some reason if I am running on an update function, I am only able to generate about 30 blocks a second, when my framerate is upwords of 300... This is the same for Delete(gameobject)...
Please help - Max
If you want to get technical Update occurs more often than frames do. Likely the engine has some sort of internal limitation to prevent massive instantiation bursts. $$anonymous$$inecraft actually instantiates fairly slowly when possible.
I'm surprised you have access to Unity 5 without understanding that Instantiate and Destroy are slow. $$anonymous$$y understanding is that the its still in closed beta. Only a few experienced and trusted developers have access. If you are using an illegal version I would strongly suggest you drop back to the currently supported free version. Otherwise you can take questions straight to your contact at Unity Technologies who provided you with the beta.
tags mean nothing, tags are to expand the wide range on which a post gets posted, so no I do not have Unity5, but yes I will continue to use the tags I want, so don't act like a child and go completely off subject.
Answer by dmg0600 · Sep 22, 2014 at 11:34 PM
Instantiate and Destroy are really slow instructions. You should use a pool of GmaeObjects instead of creating and destroying them.
Take a look at this pool tutorial.
If it does not set it clear for you, do some reserach as there are plenty of answers about GameObjects pools.
thanks I was thinking of doing that, but I didn't think of a great place to start. Thanks for the link
Answer by 767_2 · Sep 22, 2014 at 11:36 PM
Instantiate and Destroy methods of unity are slow because of garbage collection and the alternative that is mostly used is object pooling , that you can make an object pooling system of your own (tutorial)or use a plugin like poolManager
Answer by Kiwasi · Sep 23, 2014 at 12:03 AM
For minecraft like games you should consider using a voxel generation method, instead of handling individual objects. This basically cheats by creating one huge GameObject, and modifying it as individual cubes are added and removes.
Object pooling also works