feat: 加入摄像头移动限制

This commit is contained in:
meishibiezb
2026-03-15 23:37:49 +08:00
parent b76f44fcc7
commit 07afc8a00b
2 changed files with 6 additions and 1 deletions

View File

@@ -27,7 +27,10 @@ void ACameraPawn::CameraMove(const FInputActionValue& Value)
auto r = GetActorRightVector(); auto r = GetActorRightVector();
auto f = r.Cross(FVector::UpVector); auto f = r.Cross(FVector::UpVector);
f.Normalize(); f.Normalize();
SetActorLocation(GetActorLocation() + f * f2d.X * MoveSpeed + r * f2d.Y * MoveSpeed); auto l = GetRootComponent()->GetRelativeLocation() + f * f2d.X * MoveSpeed + r * f2d.Y * MoveSpeed;
l.X = FMath::Clamp(l.X, -CameraMoveClamp, CameraMoveClamp);
l.Y = FMath::Clamp(l.Y, -CameraMoveClamp, CameraMoveClamp);
SetActorRelativeLocation(l);
} }
void ACameraPawn::CameraReset(const FInputActionValue& Value) void ACameraPawn::CameraReset(const FInputActionValue& Value)

View File

@@ -33,6 +33,8 @@ public:
float MaxArmLength = 3000.0f; float MaxArmLength = 3000.0f;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
float MinArmLength = 300.0f; float MinArmLength = 300.0f;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
double CameraMoveClamp = 800.0;
UFUNCTION(BlueprintCallable, Category = "Camera") UFUNCTION(BlueprintCallable, Category = "Camera")
void CameraZoom(const FInputActionValue& Value); void CameraZoom(const FInputActionValue& Value);