- Home /
IOS Object Pooling
Hi,
I've been looking through unitys docs reading about IOS optimization for my game and am now wondering whether it would make sense to use object pooling in the following case:
During the 2-3 minute gameplay in my game around 80-120 game objects are thrown by the character.
Each projectile is a simple prefab with a mesh of about 100 vertices and currently I have just been using Instantiate and Destroy to manage them, with no concern for memory management.
There are only ever about 6 projectiles in game at one time, so an object pool would seem like a possible solution to lower any memory usage.
Would it make sense in this case to try create an object pool rather than the current instantiate method? (I'm guessing yes)
And also each time a projectile hits it instantiates a particle system - should I create another object pool for the hit particles? (I'm guessing yes again)
Just want to make sure it would make sense to create an object pool before I begin coding.
Thank you very much
sure, almost everything, in any video game, is a pool
(You simply do not instantiate, during game play, for any reason)
here is a massive discussion:
http://answers.unity3d.com/questions/321762/how-to-assign-variable-to-a-prefabs-child.html
pls vote it up if helpful :)
I think also it's worth noting. Questions like this often come up "what is more efficient". Say you had to decide on two 'different" pooling strategies. ($$anonymous$$aybe, 4 separate pools, or, one pool with changing objects ... say.) the fact is you just have to do it both ways and check. That's how game production goes. I mean it's only a few lines of code either way.
$$anonymous$$y point is just that you often get questions where people are keen to know which will be quicker. Almost always the answer is "take ten $$anonymous$$utes to try it each way and compare". So just bear that in $$anonymous$$d in your travels also!
But yeah, don't instantiate
Wow that is a very detailed answer you posted - should be plenty of reading material ;)
I will have to try out different pools and see what works best.
Just wanted to make sure I understood the concept properly, when to use it, and if there were any alternative approaches.
Thanks for taking the time!
it is my pleasure AND I both noticed and appreciated you voted it up on that page -- WHOO 25 votes !!
thank you !
No problem, the answer definitely deserves the votes.. very entertaining too.
Got the object pool up and running!
Cheers