Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. void ASpaceFlightPawn::MoveRightInput(float Val)
  2. {
  3.     // Target yaw speed is based on input
  4.     float TargetYawSpeed = (Val * TurnSpeed);
  5.  
  6.     // Smoothly interpolate to target yaw speed
  7.     CurrentYawSpeed = FMath::FInterpTo(CurrentYawSpeed, TargetYawSpeed, GetWorld()->GetDeltaSeconds(), 2.f);
  8.  
  9.     // Is there any left/right input?
  10.     const bool bIsTurning = FMath::Abs(Val) > 0.2f;
  11.  
  12.     // If turning, yaw value is used to influence roll
  13.     // If not turning, roll to reverse current roll value.
  14.     float TargetRollSpeed = bIsTurning ? (CurrentYawSpeed * 0.5f) : (GetActorRotation().Roll * -2.f);
  15.  
  16.     // Smoothly interpolate roll speed
  17.     CurrentRollSpeed = FMath::FInterpTo(CurrentRollSpeed, TargetRollSpeed, GetWorld()->GetDeltaSeconds(), 2.f);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement