Hi!
I want to use the MoveComponentTo function but it doesn’t work. This is my code:
#include "Board.h"
#include "Components/StaticMeshComponent.h"
#include "Kismet/KismetSystemLibrary.h"
// Sets default values
ABoard::ABoard()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = false;
VisualComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BoardVisualComponent"));
NavigatorComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("NavigatorVisualComponent"));
VisualComponent->SetupAttachment(RootComponent);
NavigatorComponent->SetupAttachment(VisualComponent);
}
// Called when the game starts or when spawned
void ABoard::BeginPlay()
{
Super::BeginPlay();
StartMovingNavigator();
}
// Called every frame
void ABoard::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void ABoard::StartMovingNavigator()
{
UE_LOG(LogTemp, Warning, TEXT("NavigatorLocation %s"), *NavigatorComponent->GetRelativeLocation().ToString());
UKismetSystemLibrary::MoveComponentTo(
NavigatorComponent,
FVector(0.3f, -0.3f, 0.13),
FRotator::ZeroRotator,
false,
false,
7.0,
false,
EMoveComponentAction::Move,
FLatentActionInfo());
}
The UE_LOG
outputs:
LogTemp: Warning: NavigatorLocation X=0.300 Y=0.300 Z=0.013
Why doesn’t it move?