Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ASpaceFlightPawn::MoveRightInput(float Val)
- {
- // Target yaw speed is based on input
- float TargetYawSpeed = (Val * TurnSpeed);
- // Smoothly interpolate to target yaw speed
- CurrentYawSpeed = FMath::FInterpTo(CurrentYawSpeed, TargetYawSpeed, GetWorld()->GetDeltaSeconds(), 2.f);
- // Is there any left/right input?
- const bool bIsTurning = FMath::Abs(Val) > 0.2f;
- // If turning, yaw value is used to influence roll
- // If not turning, roll to reverse current roll value.
- float TargetRollSpeed = bIsTurning ? (CurrentYawSpeed * 0.5f) : (GetActorRotation().Roll * -2.f);
- // Smoothly interpolate roll speed
- CurrentRollSpeed = FMath::FInterpTo(CurrentRollSpeed, TargetRollSpeed, GetWorld()->GetDeltaSeconds(), 2.f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement