Playmaker Forum

PlayMaker Updates & Downloads => Share New Actions => Topic started by: ergin on June 06, 2016, 10:31:50 AM

Title: Pooler - Simple Pooling System.
Post by: ergin on June 06, 2016, 10:31:50 AM
Hello, I wrote a simple pooling system for my project and wanted to share with community.

Use "Pooler Pool" Action to pool any number of objects you need. Then by using "Pooler Spawn" you can enable objects instead of instantiating them during the game. By using "Pooler Destroy" you can disable pooled objects so that you can re-use them when neccesary. Pooler pool has the ability to grow the pool if neccesary but it's optional.

https://github.com/ergin3d/PlayMakerCustomActions_U5/tree/master/Assets/PlayMaker-Custom-Actions/Pooler (https://github.com/ergin3d/PlayMakerCustomActions_U5/tree/master/Assets/PlayMaker-Custom-Actions/Pooler)

This is my first upload to ecosystem, so I'm unsure if I uploaded to right place or followed the right steps.

Also for the coding I can't say I am an expert coder. I hope some pros here can check the code. ;)

Thanks.
Title: Re: Pooler - Simple Pooling System.
Post by: dudebxl on June 06, 2016, 11:34:28 AM
Hi,

Thx a lot...

Question:
i have used another pool manager and on each spawn, i had to manually by send event restart my fsm.. So spawn (fsm works on start, depawn, spawn (send event to get the fsm to work).
With yours, when spwan then despawn then spawn, does it start the fsm or will i have to manually activate the fsm?
Title: Re: Pooler - Simple Pooling System.
Post by: ergin on June 06, 2016, 12:41:37 PM
Hello and Thanks!

I hope I didn't misunderstand the question.

When I pool, then spawn, then despawn(destroy) and spawn again, object is disabled and then re-enabled. By default when an object with FSM is disabled then re-enabled it starts from the begining "start" event. So there is no need to send any event.

Edit: Spelling
Title: Re: Pooler - Simple Pooling System.
Post by: dudebxl on June 06, 2016, 01:09:18 PM
Cool thx... I will try it in my next project..  :)
Title: Re: Pooler - Simple Pooling System.
Post by: KellyRay on June 06, 2016, 03:44:04 PM
Thanks Ergin! Will check this out
Title: Re: Pooler - Simple Pooling System.
Post by: PlaymakerNOOB on June 29, 2016, 11:17:03 PM
I am using this pooling system and it seems great... until I restart the scene.  Then I am getting the following errors in console log.  Unity 5.3

--start of console log--
Pooler: Same pool exists, choose unique names for pools
UnityEngine.Debug:Log(Object)
HutongGames.PlayMaker.Actions.PoolerPool:PoolObjects() (at Assets/Custom Playmaker/Pooling System/PoolerPool.cs:145)
HutongGames.PlayMaker.Actions.PoolerPool:OnEnter() (at Assets/Custom Playmaker/Pooling System/PoolerPool.cs:59)
HutongGames.PlayMaker.FsmState:ActivateActions(Int32) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:200)
HutongGames.PlayMaker.FsmState:OnEnter() (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:168)
HutongGames.PlayMaker.Fsm:EnterState(FsmState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2155)
HutongGames.PlayMaker.Fsm:SwitchState(FsmState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2113)
HutongGames.PlayMaker.Fsm:UpdateStateChanges() (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2041)
HutongGames.PlayMaker.Fsm:UpdateState(FsmState) (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2171)
HutongGames.PlayMaker.Fsm:Update() (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1425)
PlayMakerFSM:Update() (at c:/Users/Alex/Documents/Unity/Playmaker/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:435)

MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
--End of console log--
Title: Re: Pooler - Simple Pooling System.
Post by: ergin on June 30, 2016, 04:59:34 AM
Hello,

as for the first line of debug you have different pools with same name. Can you please try to find if there are different pooled objects with same pool name? Also a pool should only be initialized only once. You may be attempting to initialize the same pool twice.

As for the ---"MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object."---

My script doesn't destroy objects but disables them I don't think pooler generates this log. Is this a test scene? if it is can you please send it to me?

ergin@sitailetisim.com

Thanks.
Title: Re: Pooler - Simple Pooling System.
Post by: PlaymakerNOOB on June 30, 2016, 06:33:28 PM
thanks, i've sent you an email with my box link for download.

I've deleted pretty much everything except whats necessary to create a basic version.
Title: Re: Pooler - Simple Pooling System.
Post by: ergin on July 01, 2016, 01:50:49 AM
Thanks. I fixed the problem. Actually it was my fault. I'm using this action in my project I never needed to restart a scene in my game.

When a scene is reloaded, object arrays where spawned instances are stored do not reset but all the spawned objects are deleted because of a reload. I solved it by adding an awake() function which executes when a scene is loaded and resets arrays.

You can download new version:
https://github.com/ergin3d/PlayMakerCustomActions_U5/blob/master/Assets/PlayMaker-Custom-Actions/Pooler/PoolerPool.cs (https://github.com/ergin3d/PlayMakerCustomActions_U5/blob/master/Assets/PlayMaker-Custom-Actions/Pooler/PoolerPool.cs)

Thanks again.
Title: Re: Pooler - Simple Pooling System.
Post by: PlaymakerNOOB on July 01, 2016, 06:51:04 AM
thanks, it works!
Title: Re: Pooler - Simple Pooling System.
Post by: ergin on July 01, 2016, 02:33:04 PM
you're welcome...  :)
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on March 04, 2018, 08:43:28 AM
Hi.
I would like to ask if i can place these actions on the Ecosystem so they are easy to access.
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on March 07, 2018, 03:37:38 AM
Hi.
pooler Pool Actions are now available on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) !
Title: Re: Pooler - Simple Pooling System.
Post by: part12studios on July 12, 2018, 02:46:46 PM
I know this is a very old thread, but i'm new to Playmaker and interested in pooling.  I see the files and they are still out there, but I don't see anywhere about how I would "install" these files so they work in playmaker.  .cs files? 

Thanks,
Caleb
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on July 12, 2018, 02:53:48 PM
Hi.
Click on the link "Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)"
Download and install the file into your project.
Then in the plamaker menu Playmaker/Addons/Ecosytem click on the Ecosystem browser.

This will open a window.

Then Search for 'Pooler' and get the package :D

By the way, there will be native pooler actions in (i believe) the next patch.
Title: Re: Pooler - Simple Pooling System.
Post by: Fat Pug Studio on July 13, 2018, 03:19:37 AM
Hi guys, are these the actions that will be included as a native pooling due for 1.9.1 or you're making in-house actions? If so (i know there's another topic for that, but it doesn't hurt to mention it again) is there a chance of putting in an option to reset local variables on newly pooled items?
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on July 13, 2018, 09:25:23 AM
Hi.
No these will be different actions.
I believe jean is working on these, i will forward the suggestion.
This would be very useful indeed and also good if it is optional.
Title: Re: Pooler - Simple Pooling System.
Post by: jeanfabre on July 18, 2018, 04:48:16 AM
Hi,

 yep, this is all coming, reset is being studied and is part of the beta, so I expect this to be available when the internal pool system will be out too.

 Bye,

 Jean
Title: Re: Pooler - Simple Pooling System.
Post by: PlaymakerNOOB on April 25, 2019, 03:59:17 PM
Where can we keep up to date on the status of the pooling system? I didnt see it on the trello board.
Title: Re: Pooler - Simple Pooling System.
Post by: jeanfabre on May 17, 2019, 01:15:28 AM
Hi,

 Updates on the pooling system will come thru the regular beta cycles.

 Bye,

 Jean
Title: Re: Pooler - Simple Pooling System.
Post by: nuFF3 on July 21, 2019, 12:17:28 PM
EDIT2
Seems this pooler is really REALLY broken.
I've got it to function properly, kinda, by having it execute the 'Pooler Pool' a fraction of a second later than start. Now it works pretty much every time.
It's enough to use a 'Next Frame Event'.

But if it's within the first state during start, its like rolling a dice to see if it works or not.

Why is its like this?

END OF EDIT2



EDIT1
I just tried it, and it seems rather temperamental. Actually, the pooler seems really broken in general.
Sometimes it works just fine, other times it doesn't work at all.

I've got no clue...

END OF EDIT1

I've got a question.

I work with several prefabs that use the 'Pooler Pool', and if the name of the pool has the same name, it tells me to set a unique name for each pool.

So my question is:
Is it possible to create the pool and activating its pooled objects by another 'Pooler Spawn'?
You know, like:
Object 1 creates pool using 'Pooler Pool', names pool "pool 1".
Object 2 uses 'Pooler Spawn' with the name "pool 1".

Or does both actions have to be within the same object? Same FSM?

Otherwise I have to set up a random naming scheme for each prefab copy. That seems rather tedious imo.
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on July 21, 2019, 03:28:06 PM
Hi.
Pooler is a basic pool system made by someone from the community.

If you pre-load several objects in pooler you might indeed need to wait till its ready.

'Pooler spawn' should be able to spawn from a different object/fsm (after its loaded)

For 1 pool you can only use 1 name as it needs to reference from which pool it needs to spawn something.
Title: Re: Pooler - Simple Pooling System.
Post by: nuFF3 on July 21, 2019, 03:51:59 PM
Hi.
Pooler is a basic pool system made by someone from the community.

If you pre-load several objects in pooler you might indeed need to wait till its ready.

'Pooler spawn' should be able to spawn from a different object/fsm (after its loaded)

For 1 pool you can only use 1 name as it needs to reference from which pool it needs to spawn something.

Yes, I've been toying with it for a while, but I've never had this issue of it not working before.
Basically it started to spit out errors/warnings whenever I tried to spawn anything from the pool.
Errors like:
"Pooler: No Such Pool, try using variables for pools names to avoid mistyping."
and
"Pooler: Can't Spawn, max. instances reached?"
even when the pool is created.
BUT, not if I wait one frame or so with the pooling, not spawning from the pool.

This is the sequence that doesn't work:
Scene starts -> 'Pooler Pool' is in the 'start' state -> several seconds later I need to spawn something from the pool -> it spits out errors/warnings.
But if I do the same sequence, but wait one frame before I start the 'Pooler Pool', then it's all hunky dory.
This doesn't make sense to me.
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on July 21, 2019, 06:43:22 PM
Hi.
I tried to repo on a clean project, but i can't seems to repo here.

tested on Unity 2810.4.2f1 and playmaker 1.9.0p17

Does Creating a pool in @start always gives this error on your end?

Is it a large project? do you have many pooler pool action at start?

Are you initially pool object and if so how many?

So far i only get an error if i set 'Initially Pooled Objects to 0 and Max Pooled Objects to any value greater than 0 + Can Grow set to false

In my recent projects i am not using pooler anymore so i can't really test on a larger project.
Title: Re: Pooler - Simple Pooling System.
Post by: nuFF3 on July 22, 2019, 04:42:35 AM
Does Creating a pool in @start always gives this error on your end?

Only when the pool is created in one object's fsm, to then be used by another object.

Is it a large project? do you have many pooler pool action at start?
Currently its not a very large project no, as for how many? Three in total I think.

Are you initially pool object and if so how many?
The one in question is 20.

BTW, I've never had this issue if the pool and spawner is in the same fsm or object. By having both in the same fsm and object I've managed to pull off thousands of instanced objects with no problem.

This seems to be entirely something to do with having the pool created outside the fsm where the spawner is.
Title: Re: Pooler - Simple Pooling System.
Post by: nuFF3 on July 22, 2019, 05:33:49 AM
Got it to work again... no idea why, but it works properly now.
And I'm ready to pull my hair out.

Might have been because I started cleaning up my project, removing redundancies etc.

I should probably stop thinking about it, because it's going to give me an aneurysm.
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on July 22, 2019, 07:36:51 AM
Hi.
I'm happy it works now.

For the  Playmaker pool system there is not Eta yet.

It's been a while since i used Pooler, as now i am using Lean Pool.

It does not have playmaker actions included, But i have a action bundle for it on my TPA asset.

But for basic stuff pooler should be fine :)
Title: Re: Pooler - Simple Pooling System.
Post by: PlaymakerNOOB on July 22, 2019, 10:14:52 AM
Quote
It's been a while since i used Pooler, as now i am using Lean Tween.

Pretty sure you meant to say, you are using Lean Pool with playmaker actions for your pooling needs.
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on July 22, 2019, 10:34:36 AM
Hi.
@PlaymakerNOOB :
Ah yes, corrected it, thanks for noticing and mentioning :)
Title: Re: Pooler - Simple Pooling System.
Post by: ViRiX Dreamcore on September 24, 2019, 08:42:15 PM
Was this updated? I'm getting a nullreference error on PoolerSpawn.
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on September 25, 2019, 08:14:02 AM
Hi.
Did you use Pooler Pool 1st
Title: Re: Pooler - Simple Pooling System.
Post by: Gua on December 11, 2019, 07:05:41 AM
@ergin, Thank you very much for those actions!
Title: Re: Pooler - Simple Pooling System.
Post by: kingssman on February 20, 2023, 05:57:08 AM
When using the puller, the console says "Poller: Unable to create, max instances reached?" The message keeps appearing. What could be the reason and how can I fix it?
(The pool's max pooled objects setting is set to 0 (no limit).)
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on February 20, 2023, 10:00:55 AM
Hi.
Have you created a pool before pooling?
Title: Re: Pooler - Simple Pooling System.
Post by: kingssman on February 20, 2023, 10:34:06 AM
Yes, I created a pool and spawned it.