Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: rizwanash on July 05, 2019, 03:43:07 AM

Title: Safest way to destroy objects.[SOLVED]
Post by: rizwanash on July 05, 2019, 03:43:07 AM
Hey guys,

I would like to know what is the easiest and/or safest way to destroy spawned objects in the scene, for e.g. Bullets and particles etc. destroy object seems to be removing first one only which is of course how it is set to do. is there any way we can collect all of the clones being created and then destroy them?

Thanks
Title: Re: Safest way to destroy objects.
Post by: jeanfabre on July 05, 2019, 04:19:28 AM
Hi,

 many ways:

-- you make a manager that maintain a list of the clones, and then it can destroy them all, because it can go through that list

--  parent all clones to the same gameobject, then you can destroy just the parent

-- make a global event "DESTROY XXX" and any fsm listening to that will then destroy itself, which probably the most effective and direct way, because more fsm can listen to this yet act differently depending on the context, and exceptions are easy to make. I use this a lot myself

Bye,

 Jean
Title: Re: Safest way to destroy objects.
Post by: rizwanash on July 05, 2019, 04:24:04 AM
Where should i start this event Destroy Bullets lets say, when it spawns right after that or when i destroy first object ?
Title: Re: Safest way to destroy objects.
Post by: jeanfabre on July 05, 2019, 04:26:23 AM
Hi,

 When you want to destroy it.

Bye,

 Jean
Title: Re: Safest way to destroy objects.
Post by: rizwanash on July 05, 2019, 04:32:01 AM
Alright, Thanks very much....
Title: Re: Safest way to destroy objects.[SOLVED]
Post by: djaydino on July 05, 2019, 11:53:34 AM
Hi.
For bullets you might want to look into pooling them instead of create/destroy

There is a set of pooling actions called pooler it's not very advanced but i can do the job.

i am using pooler in this tutorial :