I have an Actor as below
UCLASS()
class AMyActor : public AActor
{
GENERATED_BODY()
UPROPERTY(VisibleAnywhere)
USceneComponent* DefaultSceneRoot;
UPROPERTY(VisibleAnywhere)
UStaticMeshComponent* StaticMeshComp;
UPROPERTY(VisibleAnywhere)
USpringArmComponent* SpringArmComp;
UPROPERTY(VisibleAnywhere)
UCameraComponent* CameraComp;
...
};
...
AMyActor::AMyActor()
{
PrimaryActorTick.bCanEverTick = true;
DefaultSceneRoot = CreateDefaultSubobject<USceneComponent>("DefaultSceneRoot");
RootComponent = DefaultSceneRoot;
StaticMeshComp = CreateDefaultSubobject<UStaticMeshComponent>("StaticMesh");
SpringArmComp = CreateDefaultSubobject<USpringArmComponent>("SpringArm");
CameraComp = CreateDefaultSubobject<UCameraComponent>("Camera");
StaticMeshComp->SetupAttachment(DefaultSceneRoot);
SpringArmComp->SetupAttachment(DefaultSceneRoot);
CameraComp->SetupAttachment(SpringArmComp);
}
The actor is inherited by blueprint and created in scene
In scene attachment hierarchy
but it seems only the root component got set properly. All attached components were detached.
am I doing any thing wrong?