Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Pooly - Professional Pooling System

Discussion in 'Assets and Asset Store' started by sharkyro, Mar 7, 2017.

  1. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    @BryanO The script you have there needs to be attached to the GameObject holding your trigger. The spawner can be anywhere, as long as you correctly reference it (make the "spawner" variable public and link it in the Inspector).

    Don't forget to have a rigidbody on the GameObject that enters the trigger (aka your player) and to have both collider and trigger on physics layers that interact.

    Cheers,
    Alex.
     
  2. tcmeric

    tcmeric

    Joined:
    Dec 21, 2016
    Posts:
    181
    Hi, is there a way to get a random prefab by category from pooly? For example, I want a particle effect prefab from pooly for an explosion. On pooly I have a category called "explosion" that has 4 options. Any method I can call to spawn just 1 of the prefabs at random?
     
  3. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @tcmeric! The simplest way to do it would be via a Pooly Spawner. Take a look at this video tutorial where we show how to spawn random visual & sound effects when picking up an item.

    PlayMaker actions are now available for the spawner, as well. If needed, you can control the spawner directly from FSM and also have the option to receive a reference to the spawned clone's GO. Our newest tutorials (released yesterday) show a good overview of the PlayMaker actions. We're still working on the 3rd and final video that goes into details regarding the actions for the spawner, but we expect it to be released in a couple if days.

    Cheers,
    Alex.
     
    Last edited: Mar 28, 2018
    tcmeric likes this.
  4. lotusexchange

    lotusexchange

    Joined:
    Dec 23, 2017
    Posts:
    3
    Hi, do I have to despawn all active prefabs before switching to another scene?:rolleyes:
     
  5. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @lotusexchange

    Anything pooled under Pooly's Main Pool is permanent, only PoolyExtensions are destroyed and cleaned up when a scene is unloaded. Generally speaking, yes, you should despawn all prefabs before switching scenes.

    Cheers,
    Alex.
     
    lotusexchange likes this.
  6. lotusexchange

    lotusexchange

    Joined:
    Dec 23, 2017
    Posts:
    3
    Hi again,
    When we spawning prefabs in PoolyExtention, Transform assignment is not working.. (example below)
    This method is working fine with basic Pooly.
    Is it impossible to use Transform assignment with PoolyExtention?


    Transform enemy = Pooly.Spawn("enemy1", position, rotation);
     
  7. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    @lotusexchange The transform reference will be returned, no matter where the prefab is being pooled. If you're not getting a reference back, it means that there are no clones available (yet).

    Take note, that PoolyExtensions will add their clones to the pool at the end of the frame after OnEnable (by default, at the end of the first frame). So, if you try to spawn something from a PoolyExtension in the first frame it won't work, because the clones are not yet available.

    In general, it's best to avoid trying to spawn in the first frame of a scene, to allow the sytem to properly set itself up.
     
    lotusexchange likes this.
  8. jGate99

    jGate99

    Joined:
    Oct 22, 2013
    Posts:
    865
    Hi does your plugin support pooling of simple objects like a StudentClass etc?
     
  9. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @AmRafay1

    Our asset supports the pooling of prefabs, nothing else. If your simple objects are Unity prefabs, they can be pooled with Pooly.
     
  10. lotusexchange

    lotusexchange

    Joined:
    Dec 23, 2017
    Posts:
    3
    Pooly Spawner can apply only 1 spawn condition.. Do I have to create muntiple Pooly Spawner instance in order to use different spawn condition for each prefabs?
     
  11. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    @lotusexchange A Pooly Spawner is designed to perform one single task. If you need more (which seems to be your case), feel free to use as many spawners as you need.
     
    lotusexchange likes this.
  12. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    50
    hi Sharkyo, I am getting an error thrown with the latest version that 'unable to parse YAML file'.

    Unable to parse YAML file: [Invalid trailing UTF-8 octet] at line 0. It throws 53 instances of this error in the console.

    Happens on 2017.4 and 2018. Any ideas?
     
  13. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @starfoxy

    This is a Unity bug. You can find a lot of ideas on how to fix it on google. When I encountered this problem in the past, this youtube tutorial proved to be most helpful.
     
  14. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    50
    Thank you Sharkyo! Ah the joys of Unity bugs.
     
    sharkyro likes this.
  15. tosiabunio

    tosiabunio

    Joined:
    Jun 29, 2010
    Posts:
    107
    Will it work with UI prefabs as well?
     
  16. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @tosiabunio
    It will work, but you will need to be careful how the prefabs are handled. Pooly only works with Transforms, it will not take into account any RectTransform settings. Anything related to the RectTransform you will need to handle yourself via OnSpawned()/OnDespawned() methods (especially if you re-parent prefabs under a canvas after spawning them).
     
    tosiabunio likes this.
  17. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    176
    Yeah this is oddly happening now too. It seems like some images don't load because of it.
     
  18. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @Blueberry
    Those errors sometimes happen due to Unity performing some internal work on its own files (like *.meta files and others). This sort of errors are nothing to be worry about if they go away after the import has finished.
    Do you experience eny errors after the initial import of the asset?
     
  19. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    176
    Code (csharp):
    1. Unable to parse file Assets/Ez/Shared/Images/General/sideButtonHelpHover.png.meta: [Control characters are not allowed] at line 0
    Code (csharp):
    1. Unable to parse YAML file: [Control characters are not allowed] at line 0
    Repeats a lot of stuff like this.


    - But I thought this screen was supposed to be more... green? Unless that was an older version.
    poolywindow.png
     
  20. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    This is 100% Unity related, it has nothing to do with Pooly. This occurs because Pooly was published with support for older versions and when you import it into a newer version, Unity does some internal upgrading work.
    These errors shouldn't occur more than once - when you import the asset. It this happens repeatedly, try re-importing the asset.

    No, that looks right, there's no problem there :) There were a few changes to improve the contrast, especially for the Personal skin.
     
  21. Nickolauson

    Nickolauson

    Joined:
    Sep 18, 2013
    Posts:
    5
    Hey @sharkyro.

    I've a little request :) It's a known fact that if you have a lot objects which moves, they will perform better in the root of scene (check this blog post). You can make a quick test, i.e. instantiate 10k cubes with rigidbody components and trigger colliders and move them randomly (using one Update() in manager script). 10k cubes will perform noticeably faster in the root of the scene, than if they would be inside of any parent object.

    So, is there any possibility to add an option (checkbox) to the component to spawn object in the root without re-parenting? Probably inside Pooly item's settings?

    If I missed this functionality, please excuse me :)

    Also, as I understood from Docs, it's possible to spawn object in root of the scene this way, correct me if I'm wrong:
    Code (CSharp):
    1. // based on Pooly.Spawn(Transform prefab , Vector3 position , Quaternion rotation , Transform parent)
    2. Pooly.Spawn (prefab,  position , rotation, null)
    3.  
     
  22. altugs

    altugs

    Joined:
    Jan 14, 2017
    Posts:
    15
    Is it possible to spawn prefabs within random scale interval, i.e. I need to spawn group of creatures, but each one will be random scaled between 0.8 - 1.2 ?
     
  23. pauldrummond

    pauldrummond

    Joined:
    Oct 30, 2014
    Posts:
    70
    Is it possible to give a spawner predefined data to control which prefabs are cloned? For example, imagine an infinite runner game where there are three scenery prefabs - left, middle and right. However, instead of spawning these randomly could I use existing data to control which prefab appears at each spawn event?

    To illustrate, the first spawn event is told to create object type 2c, object type 1b and object type 4d. At the next spawn event it is told to create object type 1a, object type 2c and object type 3d. This is repeated until we've worked through the predefined spawn settings.



    I hope this makes sense. I'm not actually creating an infinite runner game but it provides a simplified version of what I'm after.
     
  24. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @Nickolauson!
    This is a really nice suggestion! :) It's something we've wanted to do for quite a while, but never got around to actually do it.
    We'll take a fresh look at this and hopefully have this functionality available before long.

    Unfortunately, no.
    Since Pooly is a singleton, we mark it with DontDestroyOnLoad() and Unity moves it under the "DontDestroyOnLoad" scene at runtime. That is why, at the moment, re-parenting with null as the parent transform is not supported.
     
    Last edited: May 22, 2018
    Nickolauson likes this.
  25. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    The PoolySpawner doesn't currently support random scales on spawning.

    You can still implement this yourself in one of two ways:
    • Selecting a random scale and using that with the Pooly.Spawn() method
    • Having the prefab implement the OnSpawned() method in one of its scripts and changing the spawned clone's scale immediately after it is spawned
     
  26. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @pauldrummond,
    Yes, you can do that with automated PoolySpawners. Depending on your exact needs, you will probably need to chain spawners and have others act as wave spawners. I'd recommend taking a look at our tutorial series for spawners and despawners. It starts with an overview and basic tutorial and then it moves on to more advanced techniques that are suitable to be used in various scenarios:
     
  27. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    237
    Hello i use Pooly for a littel Project with Playmaker.I have a Player with a gun + Missile,Pooly work´s good for me but i have one Problem after the Player Shoot the missile and the Missile is despawn and back in the Pool,the Clone Missile have not zero Transforms in Positions and rotions,only the Position and Rotation before the Missile go back in the Pool.When i shoot after the Poolcount (like 60 ) the missile will not flying foward from the gun.How can i set it up with playmaker that the Missile have Transform : Rotation and Position zero and fly Foward (z-axis) the gun?

    Ok i have found a way to bring back the Missile to Transform Rotation and Position on all axes to zero but after the Number of clones (60) my Missile will not more fly forward from the gun,the missile will fly by left and right side and look´s ugly.
     
    Last edited: Jun 25, 2018
  28. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @Pandur1982

    When spawning a clone, Pooly can only change its position and rotation. Depending on how you work with those clones, this might not be enough.

    For example: if your missiles have Rigidbody (RB) and you work with them via Physics, any forces/velocities on those RBs will still be in effect after despawning and re-spawning that clone. That is why, when spawning a clone, you should make sure that its properties are reset (eg: set the velocity to 0, etc).

    If the number of spawned clones exceeds what is being pooled, you should increase the number of pooled items. The system can automatically instantiate new clones, if needed, but it is best to avoid this.
     
  29. Pandur1982

    Pandur1982

    Joined:
    Jun 16, 2015
    Posts:
    237
    Thx for your answer, i will test it out to Set the velocity back to zero.
     
  30. Oshigawa

    Oshigawa

    Joined:
    Jan 26, 2016
    Posts:
    252
    Hello @sharkyro

    I've been using Core Gamekit and along with it Pool Boss, but i don't need that much of a construct for pooling anymore, so i'm looking to switch.

    The thing Pool Boss is missing is something you call Pool Extension, so there's no way to break the process of instantiation into several parts, which leads to slow scene testing and long loading time. Sure, i can add items to pool on runtime, one by one which i'm not out of my mind to do, or from array, ehich is a hassle to maintain.

    Since i use one scene for the whole gameplay, can i use several deactivated Pool Extensions in the scene, and when i need items from another Pool Extension (for example Pool Extension Level 1, Pool Extension Level 2 etc.) i just activate the needed Pool Extension and only then does that Pool starts being populated?
     
  31. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hello @Kruko !

    You are correct, that is precisely how it works.

    For easier management, you can even pool the PoolExtensions themselves.
     
    Oshigawa likes this.
  32. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,008
    Hi, I'm trying to despawn gameobjects that I change the name of once spawned but I'm getting these errors:

    Is there a way I can do this? Thanks
     
  33. kulesz

    kulesz

    Joined:
    Jul 1, 2012
    Posts:
    125
    Maybe you deleted them earlier with Destroy()?
     
  34. sharkyro

    sharkyro

    Joined:
    Mar 15, 2014
    Posts:
    127
    Hi @derkoi !

    You should not rename the clones managed by Pooly. The system keeps track of its clones based on their names; if you absolutely MUST change the names of the spawned clones (although we advise against it), make sure that you revert the changes before attempting to despawn.
     
  35. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,008
    Ok thanks, I've switched to Pool Boss & that works fine with renaming.
     
  36. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    50
    Oh my this is amazing! I was just looking to see how I should approach this. I absolutely love Pooly. It's going to be so core to my future. Again, great work!
     
  37. unity_yUAfSYVSfFt1sA

    unity_yUAfSYVSfFt1sA

    Joined:
    Aug 31, 2018
    Posts:
    5
    Hi there, can I customize the number of clones in code?
     
  38. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    297
    Hi, I need set actvie/inactive the pooled clones ( not de spawnd ). How can I access specfic clones or categories

    I need methods like

    Pooly.GetPooledClones(prefab)
    Pooly.GetPooledClones(categoryName)
     
  39. Bejelit79

    Bejelit79

    Joined:
    Dec 18, 2015
    Posts:
    10
    how can I handle the scene change or reload?


    the enemy in pool extension, on reload scene, not recognize command
    player = GameObject.FindWithTag("player");
    or missing reference of player in inspector
    how resolve?

    I need to use only PoolyExtension for different object for scene
     
    Last edited: Nov 21, 2018
  40. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    297
    Hi,

    I need to this scenario, how can I achieve this;

    I have "Quest Trigger" boxes, spawned all over the map, when player take a quest, I want to set active false all other "Quest Trigger" boxes, but not despawn them.. when quest finished I want to set active true all "Quest Triggers"..

    Thanks
     
  41. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    50
    Ok so this is going to be the most basic question here but...

    Right now, I use the name string for spawn/despawn as so:

    Pooly.Spawn("mything", transform.position, transform.rotation);

    I feel like I should be referencing using transform rather than the name string like so (from the docs):

    Pooly.Spawn(Transform prefab, Vector3 position, Vector3 rotation);

    I don't understand how I can reference the transform of my prefab.

    What should 'Transform prefab' actually look like or be written? How can I achieve referencing this prefab's transform?

    Thanks to anyone who can help. :)
     
  42. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    297
    Code (CSharp):
    1. public class myclass{
    2. public transform myprefab // just drag and drop from project asset folder
    3. public void SpawnMyPrefab{
    4. Pooly.spawn(myprefab, ...)
    5. }
    6. }
     
    starfoxy and twitchfactor like this.
  43. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    50

    Thank you MoribitoMT! I had a hunch that this was the way but I thought there was some more clever way to do this without dragging a prefab into the public field. Thanks again!
     
    twitchfactor and MoribitoMT like this.
  44. heynemann

    heynemann

    Joined:
    Oct 18, 2016
    Posts:
    4
    Hey, will you be updating this asset to be compatible with Unity 2018/2019? It gives a lot of errors.
     
  45. Lab618

    Lab618

    Joined:
    Jan 12, 2015
    Posts:
    31
    I'm currently using it with Unity 2018.3.4f1 and it's working perfectly with no errors.
     
    MoribitoMT likes this.
  46. Miguelfanclub

    Miguelfanclub

    Joined:
    Jun 14, 2015
    Posts:
    14
    Great Asset!
    I have one issue, after restarting a level, the spawners wont work, even if they are initialized.
    Am i missing something?
    (working with playmaker)
     
    Last edited: Feb 19, 2019
  47. Lab618

    Lab618

    Joined:
    Jan 12, 2015
    Posts:
    31
    Where's the best place to submit a feature request? I love to be able to set up a spawn area rather than just a point or set of points.
     
  48. WWysocki

    WWysocki

    Joined:
    May 30, 2015
    Posts:
    6
    @sharkyro Is this plugin still supported?
     
    Last edited: Mar 5, 2019
    Lab618 likes this.
  49. BigToe

    BigToe

    Joined:
    Nov 1, 2010
    Posts:
    175
    I just purchased Pooly and feel it is very well done. I am trying to do some dynamic management of the pooling categories and was hoping to see if you have any recommendations. I would like to be able to create and remove categories during runtime and control some of their parameters. I found the public RemovePooledItemFromPool() function and noticed that the CreatePooledItem() was private. Changing this to public and creating an Item to feed as a parameter seems to work, but I was curious if I am missing the intended way to accomplish this? Or do you not recommend it at all?

    Thanks in advance!
     
  50. starfoxy

    starfoxy

    Joined:
    Apr 24, 2016
    Posts:
    50
    I really hope the author is still supporting this asset. It is absolutely the best pooling solution for Unity available.
     
    BigToe and Lab618 like this.