I am sure it’s just a trifle.
How can I call MoveComponentTo
in c++?
Have I to include a library?
just in case someone else needs it
#include "Kismet/KismetSystemLibrary.h"
UKismetSystemLibrary::MoveComponentTo
How you use it? I’m trying to move my camera but not work. I’ll do the same with BP and all works. This is my code:
auto* component = MyCamera->GetCameraComponent();
auto destinationLocation = DestinationCamera->GetActorLocation();
auto destinationRotation = DestinationCamera->GetActorRotation();
UKismetSystemLibrary::MoveComponentTo(
component,
destinationLocation,
destinationRotation,
true,
true,
2,
EMoveComponentAction::Move,
FLatentActionInfo());
I was using it in charactermovementcomponent, with
FLatentActionInfo info = FLatentActionInfo();
and the setting uuid, linkage, etc…
I replaced that way cause in multiplayer online with client prevision, the server reset the movement every time.
During performmovement i call a void with deltasecond param where
if (bShouldMove)
{
FVector difference = DestinationVector - GetActorLocation();
if (!difference.IsZero())
{
FVector Result = difference / FVector(DestinationTime);
if (Result.ContainsNaN())
{
if (FMath::IsNaN(Result.X) || !FMath::IsFinite(Result.X)) Result.X = 0.0f;
if (FMath::IsNaN(Result.Y) || !FMath::IsFinite(Result.Y)) Result.Y = 0.0f;
if (FMath::IsNaN(Result.Z) || !FMath::IsFinite(Result.Z)) Result.Z = 0.0f;
}
Velocity += Result;
}
}
if you use it with pawn, the velocity is really high with small destinationtime and you’ll kill your actor with the impact