I have a problem and I found no reason, why it happens and how I solve it:
I have a paper character, that adds some components to it:
AEntity::AEntity()
{
PrimaryActorTick.bCanEverTick = true;
SwordVisual = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SwordVisual"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> SwordVisualAsset(TEXT("/Game/StarterContent/Shapes/Shape_Sphere.Shape_Sphere"));
if (SwordVisualAsset.Succeeded())
{
SwordVisual->SetStaticMesh(SwordVisualAsset.Object);
SwordVisual->SetWorldScale3D(FVector(0.8f));
}
SwordVisual->AttachTo(RootComponent);
SwordSphere = CreateDefaultSubobject<USphereComponent>(TEXT("SwordSphere"));
SwordSphere->AttachTo(SwordVisual);
SwordSphere->InitSphereRadius(40.0f);
SwordSphere->SetCollisionProfileName(TEXT("Pawn"));
}
SwordVisual and SwordSphere are properties of AEntity. The class compiles without any problems, but when I try to run it, it looks like this:
64029-
The Sphere doesn’t attach to the character and just stays at the center of the level!
What did I wrong?