Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void UIntaxPawnMovement::Interpolate(float DeltaTime)
- {
- if (bInterpolateMovement)
- {
- if (USceneComponent* InterpComponent = GetInterpolatedComponent())
- {
- // Smooth location. Interp faster when stopping.
- const float ActualInterpLocationTime = Velocity.IsZero() ? 0.5f * InterpLocationTime : InterpLocationTime;
- if (DeltaTime < ActualInterpLocationTime)
- {
- // Slowly decay translation offset (lagged exponential smoothing)
- InterpLocationOffset = (InterpLocationOffset * (1.f - DeltaTime / ActualInterpLocationTime));
- GEngine->AddOnScreenDebugMessage(-1, -1.0f, FColor::Red, FString(TEXT("Smoothing: Decaying to root.")));
- }
- else
- {
- InterpLocationOffset = FVector::ZeroVector;
- GEngine->AddOnScreenDebugMessage(-1, -1.0f, FColor::Red, FString(TEXT("Smoothing: ZeroVector is set.")));
- }
- // Apply result
- if (UpdatedComponent)
- {
- const FVector NewRelTranslation = UpdatedComponent->GetComponentToWorld().InverseTransformVectorNoScale(InterpLocationOffset) + InterpInitialLocationOffset;
- InterpComponent->SetRelativeLocation(NewRelTranslation);
- GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Red, FString(TEXT("Smoothing: Applied smoothing.")));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement