Destroy a parent actor and it's children

I have a parent actor with two childs, when I destroy the parent using Destroy Actor function it only deletes the parent and it’s childs won’t be destroyed !

Is there a function to destroy them ?

I dont know how you do that in blueprint, but your childs need to bind this event in there owner

Theres also childrens array, but its not accessable thru blueprint

Howdy!

is right, you’ll need to call an event from the parent and bind that event in the child. Take a look at the Content Examples and the Blueprint_HUD map.

There’s an example of this for the BP_Pickup_Child_Health and BP_Pickup_Parent Blueprints. Granted the implementation might be a little different than what you are doing, but should give you an idea where to start.

-W

I am able to access that array , but components are returned as sceneComponent and since it’s it’s a component there’s a function for it called DestroyComponent but it’s only mark it !

What i understood you got 3 actors, 2 of them are owned by one actor (SetOwner). And you what to destroy owner actor the 2 owned actors should be destroyed two. So you bind those 2 owned actors to that event (in owner) i gave you.

Children array i meant this variable which is part of actor class:

And it not marked to be accessable thru blueprint

So what you basically mean is:

-At the moment I want to destroy the owner, I bind him to OnDestroyed dispatcher and inside it’s event I destroy those two owned actors ?

-so when the owner is destroyed the event inside the dispatcher fires-up and destroy those owned actors

please correct me if I’m wrong

As soon as you create a child widget from a parent widget, you should have a reference made so that you can directly call them from the parent widget. You can them add them to an array of widgets so that if you go to remove from parent on the main widget, you can instead call a function that has a for each loop to call that on all of the children blueprints and then on completed, you can remove from parent to self.

Create BP Actor Component (so can be added to any Actor) with that BP code

3 Likes