OBJECT POOLING in Unity
Video Statistics and Information
Channel: Brackeys
Views: 327,512
Rating: undefined out of 5
Keywords: brackeys, unity, unity3d, how, to, howto, learn, course, tutorial, tutorials, tip, game, development, develop, games, programming, coding, basic, basics, C#, object, pooling, performance, spawn, spawning, objects, fast, pool, enhancement, optimization, optimisation, optimise, optimize, enhance, quick, performant
Id: tdSmKaJvCoA
Channel Id: undefined
Length: 17min 23sec (1043 seconds)
Published: Sun Feb 11 2018
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Here is another flavored one I created for my game, a little more generic one using generics instead of strings etc.
Subclass
Great video. Unlike most Object Pooling tutorials this doesn't skip the very important detail of resetting your objects.
I'm using a slightly different approach. Instead of a IPoolableObject interface, I have a PooledObject component that looks like this:
Then individual components can define themselves as IPoolableComponent:
Advantages:
Another great video from Brackeys.
I wonder if this only impacts lag spikes from the garbage collector or if it has an average fps impact as well.
At last, I've been waiting for brackeys to upload object pooling.
I have a question about Pooling. This all looks easy and useful if I want to spawn and delete 100 cubes per second. Sure why not reuse them.
Now what if I have complex Class of Soldiers that have a lot of variables and references. Just "setEnabled(false)" and then true again, will be the "pooling process". But I need to reset all the values by myself, right? Restore everything to what it looks like when I instantiate a new instance for example.
A small cherry on the top would be implementing a pool with a stack instead of queue or list. It makes much more sense and it uses temporal locality.