feat: 加入摄像头旋转功能

This commit is contained in:
meishibiezb
2026-03-15 22:34:20 +08:00
parent 8d086a02fe
commit d5a469314e
6 changed files with 16 additions and 4 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -16,6 +16,9 @@ void ACameraPawn::CameraZoom(const FInputActionValue& Value)
void ACameraPawn::CameraRotate(const FInputActionValue& Value)
{
auto f = Value.Get<float>();
FRotator r = FRotator(0.0f, f * 2.0f, 0.0f);
AddActorWorldRotation(r);
}
void ACameraPawn::CameraMove(const FInputActionValue& Value)

View File

@@ -165,6 +165,10 @@ void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompone
{
EnhancedInputComponent->BindAction(CameraResetAction, ETriggerEvent::Triggered, this, &AMyCharacter::CameraReset);
}
if (CameraRotateAction)
{
EnhancedInputComponent->BindAction(CameraRotateAction, ETriggerEvent::Triggered, this, &AMyCharacter::CameraRotate);
}
}
}

View File

@@ -26,6 +26,8 @@ public:
class UInputAction* CameraZoomAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* CameraResetAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* CameraRotateAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
class TSubclassOf<class ACameraPawn> CameraActorClass;