playMaker

Author Topic: Pooler - Simple Pooling System.  (Read 21207 times)

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Pooler - Simple Pooling System.
« 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

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.

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Pooler - Simple Pooling System.
« Reply #1 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?

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Re: Pooler - Simple Pooling System.
« Reply #2 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
« Last Edit: June 06, 2016, 02:27:44 PM by ergin »

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Pooler - Simple Pooling System.
« Reply #3 on: June 06, 2016, 01:09:18 PM »
Cool thx... I will try it in my next project..  :)

KellyRay

  • Full Member
  • ***
  • Posts: 170
Re: Pooler - Simple Pooling System.
« Reply #4 on: June 06, 2016, 03:44:04 PM »
Thanks Ergin! Will check this out

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
Re: Pooler - Simple Pooling System.
« Reply #5 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--

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Re: Pooler - Simple Pooling System.
« Reply #6 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.

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
Re: Pooler - Simple Pooling System.
« Reply #7 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.

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Re: Pooler - Simple Pooling System.
« Reply #8 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

Thanks again.

PlaymakerNOOB

  • Full Member
  • ***
  • Posts: 219
Re: Pooler - Simple Pooling System.
« Reply #9 on: July 01, 2016, 06:51:04 AM »
thanks, it works!

ergin

  • Junior Playmaker
  • **
  • Posts: 86
Re: Pooler - Simple Pooling System.
« Reply #10 on: July 01, 2016, 02:33:04 PM »
you're welcome...  :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Pooler - Simple Pooling System.
« Reply #11 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.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Pooler - Simple Pooling System.
« Reply #12 on: March 07, 2018, 03:37:38 AM »
Hi.
pooler Pool Actions are now available on the Ecosystem !

part12studios

  • Playmaker Newbie
  • *
  • Posts: 41
Re: Pooler - Simple Pooling System.
« Reply #13 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

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: Pooler - Simple Pooling System.
« Reply #14 on: July 12, 2018, 02:53:48 PM »
Hi.
Click on the link "Ecosystem"
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.