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"

Proper way to child actor relationships

> Please see my related forum post

How do I properly setup parent-child relationships between two AActors in C++? Or in other words: How do I setup an Actor A to be the child of an Actor B?

An in-depth explanation of this relation is appreciated.


  • I want to auto-configure/layout a large set of actors which are in principle independent but there positions. Manual placement here is too much work and also this is intended to be part of a procedural level setup.

  • I want to re-arrange the whole actor set if certain aspects of one child actor change from within the UE4-Editor, such as position-changes.

I tried two major approaches:

Variant A

I use "AActor::AttachToActor()" which works to some extent. The NewCustomActor is attached to the current (this) AActor, which is also visible in the UE4-Editor-Outliner. However:

  • If I delete the parent AActor (this) within the editor, all child ACustomActors remain without its parent.

  • If I change an aspect in any of the child actors, this event is not propageted back to the parent actor and therefore AActor::OnConstruction() is not called, which I require. I do not want to implement a manual event propagation here, as CustomActor must also work independently of a parent-child relationship.

      ACustomActor* NewACustomActor = GetWorld()->SpawnActor(ACustomActor::StaticClass(), SpawnParams);
      NewACustomActor->AttachToActor(this, FAttachmentTransformRules::KeepWorldTransform);

Variant B

I use UChildActorComponent on the parent actor. This also works to some extent. However:

  • I could not find a solution for dynamicaly spawning UChildActorComponents as the number of objects will be only known at runtime. Using a TArray does not work as UE4-Editor then just treats it as an array and spawning / selection /editing of the child actors is not possible.

    • I cannot select any child actor from the UE4-Editor-Viewport. I always have to select the parent actor, go to its details panel, scroll down and manually select a child actor from thre. This is not practical for me, as I have hundreds of child actors and everyone of them might require manual tweaking/configuration.

    • This approach seems to be a bit of a crutch and not really intended for my purpose as it introduces an layer of indirectness which adds complexity?

        TEST = CreateDefaultSubobject(TEXT("TestX1"));
Product Version: UE 4.20
more ▼

asked Jul 27 '18 at 06:05 PM in C++ Programming

avatar image

26 1 3 7

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

0 answers: sort voted first
Be the first one to answer this question
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