Change position From A to B Over time

I wish to change object position with smooth over time, normaly in unity i used such a code:

Sound.transform.localPosition = Vector3.Lerp(Sound.transform.localPosition, DeadEnd.transform.localPosition, Time.deltaTime * speed);

I have dynamic Aim which is moving around the world but its laggy, i wish to smooth it by lerp but it is breaking during gameplay :confused: Alwso in unity i made such operations in late update function is there smth like that in unreal ?

if (once == false){
	AimActor = GetWorld()->SpawnActor<AViewfinder>(AimClass);
	once = true;
}

const FVector SpawnLocation = GunOffset + Weapon->GetSocketLocation(FName(TEXT("MuzzleFlashSocket")));
const FVector End = SpawnLocation + 1200 * Weapon->GetSocketRotation(FName(TEXT("MuzzleFlashSocket"))).Vector();
FCollisionQueryParams RV_TraceParams = FCollisionQueryParams(FName(TEXT("RV_Trace")), true, this);

RV_TraceParams.bTraceComplex = true;
RV_TraceParams.bTraceAsyncScene = true;
RV_TraceParams.bReturnPhysicalMaterial = false;
//Re-initialize hit info
FHitResult RV_Hit(ForceInit);
//call GetWorld() from within an actor extending class
GetWorld()->LineTraceSingle(
	RV_Hit, //result
	SpawnLocation, //start
	End, //end
	ECC_Pawn, //collision channel
	RV_TraceParams
	);
/*
DrawDebugLine(
GetWorld(),
SpawnLocation, //start
End,
FColor(255, 0, 0),
false, -1, 0,
12.333
);
//const FRotator SpawnRotation = GetControlRotation();
*/
AimActor->SetActorRotation(FirstPersonCameraComponent->GetComponentRotation());
if (RV_Hit.bBlockingHit == true){		
	AimActor->SetActorLocation(FMath::Lerp(AimActor->GetActorLocation(), (FVector)RV_Hit.ImpactPoint, DeltaSeconds));
}

Don’t use Lerp try FMath::VInterpTo, it’s better.

Thank you very much again :stuck_out_tongue:

#Template Function FMath::Lerp

To add to the discussion, in addition to the ever-so-wonderful FMath::VInterpTo, you can specifically supply any A to B for any data type using the templated FMath Lerp function!

FMath::Lerp<FVector>(A,B,Alpha);

FMath::Lerp<FRotator>(A,B,Alpha);

FMath::Lerp<FLinearColor>(A,B,Alpha);

Etc!

See UnrealMathUtility.h

for details!

Rama