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 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));
}