i have actors on a grid. they move through a component with the following code:
void UGridActorMoveComponent::LerpMove(FTransform source, FTransform destination)
{
Source = source;
Destination = destination;
MoveAlpha = .0f;
bIsMoving = true;
}
and
void UGridActorMoveComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
AChipsGuy* chipsguy = Cast<AChipsGuy>(GetOwner());
if (chipsguy && bIsMoving)
{
if (MoveAlpha <= 1.f)
{
FTransform transform = Source;
FVector location = FMath::Lerp(Source.GetLocation(), Destination.GetLocation(), MoveAlpha);
transform.SetLocation(location);
chipsguy->SetActorTransform(transform);
MoveAlpha += chipsguy->MoveSpeed * DeltaTime;
}
else if (MoveAlpha > 1.0f)
{
bIsMoving = false;
chipsguy->MoveDone();
}
}
}
The actor sets up Source and Destination and Movespeed, the calls LerpMove to initiate the move.
The problem now is, that it is not smooth. it always jumps a bit at the end of the move. This is very noticeable if there are repeated moves in one direction.
The Destination and Source i am sure are correct. i let them be printed on screen and they align perfectly. the end location of one move is the begin location of the next.
Can somebody help how to make the moving smooth?