Advertisement
Guest User

not working..

a guest
Dec 19th, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void UIntaxPawnMovement::Interpolate(float DeltaTime)
  2. {
  3.     if (bInterpolateMovement)
  4.     {
  5.         if (USceneComponent* InterpComponent = GetInterpolatedComponent())
  6.         {
  7.             // Smooth location. Interp faster when stopping.
  8.             const float ActualInterpLocationTime = Velocity.IsZero() ? 0.5f * InterpLocationTime : InterpLocationTime;
  9.             if (DeltaTime < ActualInterpLocationTime)
  10.             {
  11.                 // Slowly decay translation offset (lagged exponential smoothing)
  12.                 InterpLocationOffset = (InterpLocationOffset * (1.f - DeltaTime / ActualInterpLocationTime));
  13.                 GEngine->AddOnScreenDebugMessage(-1, -1.0f, FColor::Red, FString(TEXT("Smoothing: Decaying to root.")));
  14.             }
  15.             else
  16.             {
  17.                 InterpLocationOffset = FVector::ZeroVector;
  18.                 GEngine->AddOnScreenDebugMessage(-1, -1.0f, FColor::Red, FString(TEXT("Smoothing: ZeroVector is set.")));
  19.             }
  20.  
  21.             // Apply result
  22.             if (UpdatedComponent)
  23.             {
  24.                 const FVector NewRelTranslation = UpdatedComponent->GetComponentToWorld().InverseTransformVectorNoScale(InterpLocationOffset) + InterpInitialLocationOffset;
  25.                 InterpComponent->SetRelativeLocation(NewRelTranslation);
  26.                 GEngine->AddOnScreenDebugMessage(-1, 0.1f, FColor::Red, FString(TEXT("Smoothing: Applied smoothing.")));
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement