> 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:
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);
I use UChildActorComponent on the parent actor. This also works to some extent. However:
Jul 27 '18 at 06:05 PM
in C++ Programming