- Home /
Fireball instantiate - lags
Hey I have a few of skills like fireballs (2D game for Android) and I have a problem : When I launch any kind of prefab by instantiate - the game becomes very laggy for a while.
Should I rather Instantate all needed prefabs at the Start/Awake and then just enabling/disabling them? and for for example fireball bullet - when it hits sth just setactive(false) and change its position? Would it be a right way?
Thanks in Advance
The latter is indeed the best way to go, you can find a lot of information about it when you google for "Object Pooling"
Well, that's a shame that I didn't find sth connected with this topic earlier, I had to waste some time to remake my skills but that wasn't so bad after all ;) Thanks
Answer by e4lime · Aug 05, 2015 at 10:29 PM
Yes your second approach is correct, its called Object Pooling. There are scripts for that if you want to save time, here's a simple one I've used: http://forum.unity3d.com/threads/simple-reusable-object-pool-help-limit-your-instantiations.76851/