Implement Object pooling in your Unity Game

Поділитися
Вставка
  • Опубліковано 20 жов 2024

КОМЕНТАРІ • 8

  • @joaogabriellimamoraes4087
    @joaogabriellimamoraes4087 Рік тому +1

    best explanation of how to use the feature so far. Thanks!

  • @Nearueki
    @Nearueki Рік тому +1

    good explanation man, thanks very much

  • @deadadam666
    @deadadam666 Рік тому +1

    v nice , keep it up

  • @AstralNostalgia
    @AstralNostalgia 9 місяців тому

    how can I deleate and allwasy keep 10 clones? I mean I put this :
    private void Awake()
    {
    _pool = new ObjectPool(CreateProjectile , null ,OnPutBackInPool,defaultCapacity:10);
    }
    this is the method to control the maximum size of the pool right? I put 10... the problem is I see in my hierachy an accumulative objects (clones) by 10... the first time I shoot not matter , the pool deleates everything, the problem is when I pass 10, they are increaseing the number in +10...adn at the end of the day I ve a lot of Clones in the hierachy...some are deleated of course...but never keeps 10 !

    • @obviousgame
      @obviousgame  9 місяців тому +1

      Its not the max size of the pool, its the initial pool capacity. That means, when the pool is created it will allocated space for 10 objects. If you spawn more, it will increase the capacity of the pool. If you know you are going to have a certain amount of bullets at the same time, put that number as the default capacity :).

    • @AstralNostalgia
      @AstralNostalgia 9 місяців тому

      @@obviousgame I followed your tutorial , I ve created a similar class, I meant I also have a Class for weapon, but it is strange for me, when I put 10 to allocated only ten objects, always add 10 more to the first 10...probably I also reduce the time of lifeTime but it is the same for me..I am missaunderstood ? thaks.

    • @obviousgame
      @obviousgame  9 місяців тому

      @@AstralNostalgia If you come on the discord channel and post some screenshots maybe I can help you better ;)