Don't destroy child actors

Hi, this seems like it should be an easy one but I am having trouble turning up a result for this in google.

At some point I want to destroy my base actor with
pawn->Destroy();

I have already Detached some child actors from it and they are now sitting in the world. When I destroy my actor, the once child actors are destroyed too.

One last thing to note, these child actors were attached as ChildActorComponents in the editor.

How can I get my once child actors to stick around?

How do you spawn the child actors? One thing I can imagine is happening is that you’re spawning child actors with the to-be-destroyed actor as the outer/owner. Try using World instead. Let me know if it’s the case and if so if my suggestion helped.

Cheers,

–mieszko

Actors are created in the components window of the actor that was originally holding them. They are created using the ChildActorComponent. Id rather not spawn them with any code if possible.

You can override the Destroyed() function of Actor (maybe BeginDestroy too, but not sure if that’s too late) and just remove the child actors from the parent actor there to prevent them from being destroyed also. I think EndPlay should be called before the destroy sequence starts also, but that will only be called if your actor actually began play first, so maybe that’s what you want. You have options though :slight_smile:

I can’t seem to find a good way to do this. Currently, in UE4.22, when I try detaching the ChildActor component (which was set up in the BP editor) or the inner child actor itself, with the detach calls coming from either the parent actor or the inner child actor, the inner actor still gets destroyed when the original parent actor is destroyed.