Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.15
more ▼

asked Mar 12 '17 at 01:45 AM in C++ Programming

avatar image

58 13 12 19

avatar image Tain Apr 30 '19 at 11:15 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.



more ▼

answered Mar 13 '17 at 12:43 PM

avatar image

MieszkoZ STAFF
7.3k 225 57 413

avatar image Zamithal Mar 13 '17 at 04:44 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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 :)

more ▼

answered Mar 13 '17 at 09:22 PM

avatar image

703 40 32 123

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question