feat: 摄像头缩放
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user