Download

Add Child Actor component. How to destroy them with parent?

Hi guys

I use Add Child Actor Component in construction script. Parent actor are destroyed after some time, but those added child actor stay in the world.
How i can destroy child actor with parent?

In the Parent create a variable of type *ChildActorComponent *and store the reference there. Before destroying the Parent, use this reference to get rid of the component. Use an array if there’s more than one child.

On the other hand, what you’re describing should not be happening, tbh.

It seems that child actors have some issues with that right now. I just had to rip them all out of my npc’s construction scripts, because they were duplicating and being orphaned to the tune of over 40k unparented child actors being set loose on my level.

I tried to manually manage them by having the owning actor call destroy on both the component and the child actor itself, but it didn’t actually do anything.

Ironically, child actors were designed specifically to avoid this same problem with spawning regular actors in the construction script (which is why unreal won’t let you do that)