Playmaker Forum

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

Title: Pooler - Simple Pooling System.
Post by: ergin on June 06, 2016, 07: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, 08: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, 09:41:37 AM
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, 10:09:18 AM
Cool thx... I will try it in my next project..  :)
Title: Re: Pooler - Simple Pooling System.
Post by: KellyRay on June 06, 2016, 12:44:04 PM
Thanks Ergin! Will check this out
Title: Re: Pooler - Simple Pooling System.
Post by: PlaymakerNOOB on June 29, 2016, 08: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, 01: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, 03: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 June 30, 2016, 10:50:49 PM
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, 03:51:04 AM
thanks, it works!
Title: Re: Pooler - Simple Pooling System.
Post by: ergin on July 01, 2016, 11:33:04 AM
you're welcome...  :)
Title: Re: Pooler - Simple Pooling System.
Post by: djaydino on March 04, 2018, 06: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, 01: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, 11:46:46 AM
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, 11:53:48 AM
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: krmko on July 13, 2018, 12: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, 06: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, 01: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, 12: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 16, 2019, 10:15:28 PM
Hi,

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

 Bye,

 Jean