playMaker

Author Topic: Safest way to destroy objects.[SOLVED]  (Read 1283 times)

rizwanash

  • Junior Playmaker
  • **
  • Posts: 61
Safest way to destroy objects.[SOLVED]
« 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
« Last Edit: July 05, 2019, 04:41:09 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Safest way to destroy objects.
« Reply #1 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

rizwanash

  • Junior Playmaker
  • **
  • Posts: 61
Re: Safest way to destroy objects.
« Reply #2 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 ?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Safest way to destroy objects.
« Reply #3 on: July 05, 2019, 04:26:23 AM »
Hi,

 When you want to destroy it.

Bye,

 Jean

rizwanash

  • Junior Playmaker
  • **
  • Posts: 61
Re: Safest way to destroy objects.
« Reply #4 on: July 05, 2019, 04:32:01 AM »
Alright, Thanks very much....

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Safest way to destroy objects.[SOLVED]
« Reply #5 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 :