- Home /
Generating Many Objects at Once - Alternative Options?
I am working on a mobile 2D game that requires a lot of objects to be generated each session, all of which are setup relatively random (location, quantity, etc). I know that Instantiating and Destroying are memory intensive function so I am trying to avoid them so there aren't ridiculous loading times during generation.
Is there anyway that I could avoid Instantiate but still generate a large sum of objects? 10,000 is roughly the max that should ever be generated.
Do you plan on creating and destroying continuously them while the game is running? i.e., like particles, bullets, or other short lived objects. Or will they exist the whole time the player is in the scene?
Why not just instantiate them once at the games start into an array and use that as a object pool? just randomly pick from the pool and if you need to "destroy" an object you'd just disable it to get rid of it on the scene..
ShadoX, wouldn't that be the same as just instantiating them all, just they would be in an array? Or am I misunderstanding the wiki article?
The difference here is that you load them before the game is actually being played. You could put up a loading screen or something. Then, you would never have to Instantiate them again.
Your answer
![](https://koobas.hobune.stream/wayback/20220613135651im_/https://answers.unity.com/themes/thub/images/avi.jpg)