Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: dubnug on June 10, 2014, 10:29:04 PM

Title: Destroy Object action only destroying first clone? [SOLVED]
Post by: dubnug on June 10, 2014, 10:29:04 PM
Hello!

I'm running into an issue with the Destroy Object action (or how I'm using it  ;D).

I have a prefab in my assets that's being instantiated as a clone when it's dragged into the scene. So a user could pull out 5 or 10 of the same object from our UI "item library" and it'll just instantiate duplicates/clones. I have a button with an FSM that listens for a touch object event then, once fired, it'll destroy the global variable GameObject that the prefab is connected to (via Get Property).

Only issue is, it seems that only the 'first' clone instantiated is getting destroyed.. not all of the clones instantiated. I need them all to be destroyed. Is there a better way to solve this?

Title: Re: Destroy Object action only destroying first clone?
Post by: jeanfabre on June 11, 2014, 07:56:32 AM
Hi,

 yes, nothing wrong with this action, it's by design that it will only destroy the first gameobject it finds.

 I would implement a logic on the gameobject itself, and a global event "DESTROY OBJECT X" for example, and so all objects implementing this global event will be able to destroy themselves.

 This approach is very powerful, cause each object can then decide what to do based on its own properties and context.

bye,

Jean
Title: Re: Destroy Object action only destroying first clone?
Post by: semie on August 26, 2014, 09:21:27 PM
Just wanted to say thanks to OP for posting the question and thanks to Jean for his response.