playMaker

Author Topic: Pooling Set Parent  (Read 2287 times)

LuminRabbit

  • Full Member
  • ***
  • Posts: 161
  • Lumin Rabbit
Pooling Set Parent
« on: October 26, 2018, 08:37:40 PM »
Hello Fello Makers,

I have a sphere in the scene and a cube (prefab), the sphere rotates constantly, when I click a button Im shooting the cube and when it hits the sphere I turn off translate and set the cube to be the parent of the sphere so that it will stick to the face of the sphere and rotate around with it :) which was working fine.

Here's where the trouble begins. I realize its better to use a pool manager instead of creating and destroying objects but now Im not sure how to Set the parent of the cube to the sphere. Would anyone have any suggestions on what to try?

Then Im sure I'll need to figure out how moving this object under the sphere will affect the pooled clone object no longer being under the pool creation object....

Ideas greatly welcomed  ;D

 
Have I said how much I love playmaker!!! This is one amazing tool

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Pooling Set Parent
« Reply #1 on: October 27, 2018, 06:44:46 AM »
Hi.

I think it should work the same way as when you create/destroy the objects.

Depending on which pool manager you use, you might need to 'reset' the object before disabling or after creating.

How are you setting the parent of the cube to the sphere now?

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Pooling Set Parent
« Reply #2 on: December 26, 2018, 12:48:53 PM »
I just discovered these pooling actions:
https://hutonggames.fogbugz.com/default.asp?W1696
but I can't find the Pool Browser in the latest Playmaker version.
It says here this is work in progress:
https://hutonggames.fogbugz.com/default.asp?W1615
Where are these? Will these be in next update?

Anyway I already knew that creating and destroying prefabs during runtime is not the way to do it as the game will hang for a short moment every time, so what I am doing is, having the amount of prefabs I will need already in the scene, as children of an empty game object, out of the way of gameplay.
Whenever I need them in the game, I move the prefab into the game area and start events in it, then when I don't need it anymore I reset the prefab and parent it back and move it back under the storing game object.

Is this pooling?   :)
Or is pooling something better that works even faster?

Should I also deactivate these prefabs while they are stored?
(They are not doing anything and any physics object they have are removed from the simulation while they are just waiting to be reused again.)

Thanks for any insight!
Br,
szomaza

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Pooling Set Parent
« Reply #3 on: December 29, 2018, 07:54:00 AM »
Hi.
The build in pooling system is coming soon :)
It will probably be added in the next major update (not bug fix updates)

Pooling works a bit like disable/enable.


There is a simple pooling system actions on the Ecosystem which you could use for now.
Look for : pooler (package)

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Pooling Set Parent
« Reply #4 on: December 29, 2018, 12:52:00 PM »
Thank you I'll try the package out.

Is there some documentation on how pooling works and why to use it?
It would be good to have something along with the new pooling system.

I would like to understand what are the benefits of pooling, instead of just doing it myself by adding objects/prefabs before the game is running and then using/hiding/reusing those as needed.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Pooling Set Parent
« Reply #5 on: December 30, 2018, 12:35:59 AM »
Hi.
Pooling does what you are doing manually (not hiding, but disabling)

With a pooling system you can pre-define how many objects from the same prefab object you want to start with.

Then you can dynamically grow the pool if more are needed (in runtime)
and you can limit the pool to a certain amount.

if you have a single object, then manually disable/enable is good enough.
There is no need to use pooling there.

in this video pooling is explained well :


szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Pooling Set Parent
« Reply #6 on: December 30, 2018, 05:36:28 AM »
Thanks a lot, I'll watch and learn.

The embedded video is not showing for me but the link is there in the source:
https://www.youtube.com/watch?v=tdSmKaJvCoA

szomaza

  • Sr. Member
  • ****
  • Posts: 253
Re: Pooling Set Parent
« Reply #7 on: January 19, 2019, 04:48:23 AM »
In my "pooling system" I simply parent and move various elements out of the gameplay area to store them and then when needed by gameplay I reuse those same elements by moving them back and activating their functions by sending goldal event to their FSMs.

I am not disabling them while in the pool but of course the FSMs on them are not running, meaning they are not doing anything just waiting in an end state.

I assumed that these FSM scripts would not take up any resources, but checked Profiler now and found that if I disable the pool (with these objects and all stopped FSMs) while the game is running I get much better performance.
See attached image.

Why is this?
Why are the FSMs which are actually not doing anything using up resources?

I will add disabling and enabling to my pooling setup and report if it resulted in the same improvement as seen by simply disabling the whole pool parent object while the game is running.


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Pooling Set Parent
« Reply #8 on: January 21, 2019, 12:57:51 AM »
Hi.
I think the fsm itself should not have a lot of performance difference.

But if you have the playmaker editor window open and / or fsm that are not collapsed in the inspect, it can affect the profile greatly. its best to do tests inside a build.

But in theory the fsm is listening to an event, so it is not doing nothing :)

Also if your objects have things like a rigidbody it is possible that they are also getting calculated (physics)

ch1ky3n

  • Full Member
  • ***
  • Posts: 208
Re: Pooling Set Parent
« Reply #9 on: January 21, 2019, 05:40:20 PM »
Also, don't forget to calculate the need of those prefabs during your game. It is also troublesome if you keep instantiating during ingame, it is better to load 5-10 prefabs during the loading phase and keep it all hidden. You can then cycle those stuffs without the need to instantiate a new one (Hopefully)