One of the biggest problem in game development and specially in mobile game development is memory allocating and deallocating. Some OS like iOs let you take the memory you need but doesn't like the idea allocating and deallocating continuously and makes your app or game to crash.
Always a profiler (eg: Unity Profiler) is needed to see how your game do its job under the hood.
A bad practise is Instanciating and Destroy objects because they are expensive task, they do a lot of memory allocating and deallocating, generates garbage (that the garbage collector needs to collect).
So what can we do if we need to Spawn and Despwn objects in our game? The solution is the use of some kind of resources pooling.... This mean, load everything you can / need when you game is starting - instanciate objects - and mark then as Inactive. When you need one object, just look for one Inactive object in your pool, mark it as Active and use it. When you don't need anymore, mark it as Inactive. That's all.
In the case of my game, I just start using resources pools for bombs and explosions because at this moment, they are the only objects that Spawn and Despawn.
I was looking for a free, open source and easy to install / use resources pool and the solution was Prefactory_v1_0, a simple object pool manager for Unity3d. Just visit Prefactory_v1_0 web site to download it and for instructions how to use it.
I just want to thanks Boon Cotter for his excelent Pool Manager and for sharing it!
Remember, here http://bit.ly/1beCGTg you can see a live version of my game. Also, there is a new dead sound! Enjoy it
No hay comentarios.:
Publicar un comentario