Live Training Right Now!

Howdy everyone, I am doing a live training on object pooling right now: http://unity3d.com/learn/live-training

It never occurred to me to make a forum post about it until now. Come hang out!

Hi Mike,
Thanks for the training session: object pooling was a term I had heard used but which didn’t mean much - now it does.

Is this a sensible place to ask a related question? I’ll ask it and be prepared to move if not.

You describe setting up a general pool for a type of object which can be called from different places, eg lots of ships firing bullets. Is there a risk of one pooled object getting allocated to two different callers?

One caller requests a pooled object so the general pool allocates the first disabled object in its list, which the caller then processes and, in due course, enables. In the meantime, could another caller also request an object and be passed the first disabled object in the list - ie the same object - which it would also process and enable? So the bullet, say, would end up being positioned by the first ship for a tiny fraction of a second then suddenly jump to the second. The bullet initialisation code is very simple, of course, so wouldn’t take long, but a pooled enemy could take more setup before being enabled, giving more time for overlap, perhaps.

I hope the question makes sense.

Thanks again.

You made it look so easy I might just roll my own pooler now.

These are great. Watch and learn while at work. Much appreciated.

To my knowledge, the calls won’t be async, and therefore the chances of that are nill. That being said, I have not tested it and could not say for certain. I would assume you are pretty safe.

Hi Mike,

what would be your suggested approach if I want t implement 2-3 pools of different objects (ex. one pool for bullets, one pool for enemies etc.) using your generic script? Would you create many different empty objects with the ObjectPooler script attached and then link those objects ObjectPooler component via a Main Controller script somehow?

Thanks!