playMaker

Author Topic: How to Kill Parent if Child Dies[SOLVED]  (Read 1200 times)

HeathClose

  • Full Member
  • ***
  • Posts: 226
How to Kill Parent if Child Dies[SOLVED]
« on: August 15, 2017, 07:24:59 PM »
How can I destroy or deactivate a parent object (the empty holding the children) when a child is destroyed or deactivated?

I thought about a get child count and doing an int compare, but that action doesn't have every frame.
« Last Edit: August 16, 2017, 03:00:49 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: How to Kill Parent if Child Dies
« Reply #1 on: August 16, 2017, 03:00:36 AM »
Hi,

 If you have PlayMaker Utils in your project, there is a component "TransformEventsBridge" which will listen to hierarchy changes on your GameObject, it allows you to fire an event, and so use this to check only when required how many child you have and take appropriate steps then.

I also created a new custom action on the Ecosystem GetChildCount2 which will expose an everyframe option, though, it's not optimal and I suggest you use the component above.

Let me know how it goes.

 Bye,

 Jean