feat: 摄像头缩放

This commit is contained in:
meishibiezb
2026-03-15 19:16:24 +08:00
parent 877beaa3f5
commit bbe4ac4bc7
7 changed files with 18 additions and 6 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -9,6 +9,9 @@
void ACameraPawn::CameraZoom(const FInputActionValue& Value)
{
auto f = Value.Get<float>();
SpringArmComponent->TargetArmLength += f * 10.0f;
SpringArmComponent->TargetArmLength = FMath::Clamp(SpringArmComponent->TargetArmLength, 300.0f, 3000.0f);
}
void ACameraPawn::CameraRotate(const FInputActionValue& Value)

View File

@@ -149,6 +149,10 @@ void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompone
{
EnhancedInputComponent->BindAction(CameraMoveAction, ETriggerEvent::Triggered, this, &AMyCharacter::CameraMove);
}
if (CameraZoomAction)
{
EnhancedInputComponent->BindAction(CameraZoomAction, ETriggerEvent::Triggered, this, &AMyCharacter::CameraZoom);
}
}
}

View File

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