Views:2959|Rating:5.00|View Time:29:56Minutes|Likes:199|Dislikes:0
Object pooling is critical to making your game run fast and smooth. I’ll show you how to create and use a variety of pooling systems from the most tightly coupled to the most generic. We’ll save garbage allocations, improve performance, and do it all with simple reusable code!

More Info:

Join the Group:

Patreon:

Edited By Josh H.

14 comments on “Object Pooling (in depth) – Game Programming Patterns in Unity & C#

  • Small thing… instead of doing 'timed events' in void Update(), … I find it is much cleaner and clearer to IEnumerator Start() with yield new WaitForSeconds() instead, and that can be in a while(true) or a while(enabled). I get that you might want to keep the example simple and not need to explain this along with object pooling,… but just in case you didn't know about it,… it's pretty darn sexy that Start is an IEnumerator too. The best part is when you have multiple 'timeouts'/wait-timers that need to run under different circumstances… it's waaaay more pretty when it is laid out as an IEumerator in those cases, rather than having all those 'counters'/'timer' variables hanging out listening for Time.DeltaTime.

    Just food for thought.

  • Just implemented the generic version. Really instructive. I still wonder how to implement different types of bullets. Does it require to define a new class for each type of prefab (like GenericObjectPool<MyOtherType>)?
    I tried to reference the pool and call Get() from that reference, without success. Two set ups with two different bullet pools and bullet prefabs. But it's the same bullet prefab appearing in both set-ups, and only one pool is filled with instances…

  • Great video, I like the progression in the designs. Have you ever tried to completely decouple the object being pooled from the pool? So the object being pooled has no pool code / awareness?

  • You have any tips on how to keep your code manageable as it grows bigger and bigger?
    I'm having a hard time keeping my code legible as I keep adding things.
    I used to have a script that did all character functions, but now I've broken it up into Player.cs, PlayerInput.cs, PlayerMovement.cs, PlayerWeapon.cs, PlayerAbility.cs and this seemed to work fine.
    But now I'm adding multiple Weapons that all function differently like hitscan, projectile, multiple projectile, and melee.
    And abilities that are AOE, spawn objects, extra movement, controller enemy movement (like a hook), etc…

    So I started using inheritance, a base weapon class, a base ability class, a base Entity class (for players and enemies)
    but it's all becoming too much for my little brain to handle.

    Any tips on keeping it clean, coherent, and manageable?
    Have a great day! 🙂

  • Any chance Jason you would let us download your little projects? I would understand much better by following you around on my screen at the same time. The same goes for the pattern videos you do – its just kinda too fast for me plus it would be give me much better understanding if we could just look around how the things are connected

  • Really like you videos, man, but has anyone ever told you that you have a similar resemblance to the fantasy author Pat Rothfuss?

  • 21:04 But then, wouldn't it be better to make a pool of IGameObjectPool? That way were sure that the pooled object will manage their own poolability, no?

Leave a Reply

Your email address will not be published. Required fields are marked *