Best way to move a pawn in the following scenario?

Hi.

I was wondering if anyone knew the best way to move a Pawn in the following scenario:

  1. Pawn - not Character
  2. A server (not UE server) sends the
    X,Y,Z location of the Pawn every
    second
  3. The Pawn should then smoothly update
    (move to) the latest position from
    the server

What I tried that worked the best was using AddMovementInput but that requires a movement vector, not a position. Is there a way to get the input vector from 2 location vectors? Say I have where the Pawn is currently, and where I need to go, can I make a Vector out of those two to supply to AddMovementInput? Or is there a better alternative?

Thank you.

The way I achieved this in my actor class was:

void AMyActor::Tick(float DeltaTime)
{
    Super::Tick(DeltaTime);
    FVector ActorLocation= FMath::VInterpConstantTo(GetLocation(), Destination, DeltaTime, Speed);
    SetRelativeLocation(MeshLocation, true);
}

Subtracting two vectors V2 - V1 gives you a vector from V1 to V2. Normalize that vector to make it a unit vector (length=1), and you can use that as movement input.

AddMovementInput works with a world direction so you don’t even need to convert it to local space. Something like this should do the trick :

FVector V = TargetLocation - Pawn->GetActorLocation();
FVector WorldDir = V.GetSafeNormal();  // use GetSafeNormal2D if your pawn cannot fly
Pawn->AddMovementInput(WorldDir);