I have a .cpp with fragment of possibly-not-working code in initializer of the class (which is APawn):
APawn_::APawn_()
{
PrimaryActorTick.bCanEverTick = true;
innerCircle = CreateDefaultSubobject<UStaticMeshComponent>("inner");
innerCircle->SetStaticMesh(
(ConstructorHelpers::FObjectFinderOptional<UStaticMesh>(TEXT("/Game/Flying/Meshes/Player_ShpereArc.Player_ShpereArc"))).Get()
);
innerCircle->SetCollisionEnabled(ECollisionEnabled::NoCollision);
collider = CreateDefaultSubobject<USphereComponent>("collider");
outerCircle = CreateDefaultSubobject<UStaticMeshComponent>("outer");
outerCircle->SetStaticMesh((ConstructorHelpers::FObjectFinder<UStaticMesh>(TEXT("/Game/Flying/Meshes/Player_Box001.Player_Box001"))).Object);
outerCircle->SetCollisionEnabled(ECollisionEnabled::NoCollision);
RootComponent = collider;
//collider->SetRelativeLocation(FVector::ZeroVector);
innerCircle->SetRelativeLocation(FVector::ZeroVector);
outerCircle->SetRelativeLocation(FVector::ZeroVector);
collider->SetSphereRadius(75.f);
collider->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
collider->SetCollisionObjectType(ECollisionChannel::ECC_PhysicsBody);
collider->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
collider->SetSimulatePhysics(true);
}
I need to simply move innerCircle and outerCircle (static meshes) to (0,0,0) relative to root (what is sphere component). But some magic happens and when I start game the pawn spawns and meshes is in center of the map, but the root is there where it spawned. Even if i move code with SetRelativeLocation to Tick function it will not work fine. Game will move meshes only when i click on object (and select it). Overwise AddRelativeRotation is working in Tick correctly in every frame.
How does SetRelativeLocation work? What i missed?