When creating custom Actors from components, it is important to consider the concept of Attaching. Attaching components together creates a relationship where transformations applied to the parent component will also affect the components that are attached to it.
Create a new class based on
Actor
using the editor, and call itHierarchyActor
.Add the following properties to your new class:
UPROPERTY() USceneComponent* Root; UPROPERTY() USceneComponent* ChildSceneComponent; UPROPERTY() UStaticMeshComponent* BoxOne; UPROPERTY() UStaticMeshComponent* BoxTwo;
Add the following code to the class constructor:
Root = CreateDefaultSubobject<USceneComponent>("Root"); ChildSceneComponent = CreateDefaultSubobject<USceneComponent>("ChildSceneComponent"); BoxOne = CreateDefaultSubobject<UStaticMeshComponent>("BoxOne"); BoxTwo = CreateDefaultSubobject<UStaticMeshComponent>("BoxTwo"); auto MeshAsset = ConstructorHelpers::FObjectFinder...