修改摄像头的旋转逻辑

This commit is contained in:
997146918 2025-08-01 17:12:30 +08:00
parent b783586e79
commit d987f00373
8 changed files with 9 additions and 10 deletions

View File

@ -30,7 +30,7 @@ AShipbase::AShipbase()
//GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input... //GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...
//修改移动模式 //修改移动模式
GetCharacterMovement()->bOrientRotationToMovement = false; // Don't auto-orient to movement direction GetCharacterMovement()->bOrientRotationToMovement = false; // Don't auto-orient to movement direction
GetCharacterMovement()->bUseControllerDesiredRotation = true; // Use controller rotation for turning GetCharacterMovement()->bUseControllerDesiredRotation = false; // Use controller rotation for turning
GetCharacterMovement()->bUseSeparateBrakingFriction = true; GetCharacterMovement()->bUseSeparateBrakingFriction = true;
GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate
@ -182,18 +182,17 @@ void AShipbase::Move(const FInputActionValue& Value)
TurnRate *= -1.0f; TurnRate *= -1.0f;
} }
// Apply rotation to the character // Apply rotation to the character only, not the controller
FRotator NewRotation = GetActorRotation(); FRotator NewRotation = GetActorRotation();
NewRotation.Yaw += TurnRate; NewRotation.Yaw += TurnRate;
SetActorRotation(NewRotation); SetActorRotation(NewRotation);
// // Also update controller rotation for camera
// Also update controller rotation for camera // if (APlayerController* PC = Cast<APlayerController>(Controller))
if (APlayerController* PC = Cast<APlayerController>(Controller)) // {
{ // FRotator ControllerRotation = PC->GetControlRotation();
FRotator ControllerRotation = PC->GetControlRotation(); // ControllerRotation.Yaw += TurnRate;
ControllerRotation.Yaw += TurnRate; // PC->SetControlRotation(ControllerRotation);
PC->SetControlRotation(ControllerRotation); // }
}
} }
} }
} }