feat: 增加一些配置项
This commit is contained in:
@@ -10,14 +10,14 @@
|
||||
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);
|
||||
SpringArmComponent->TargetArmLength += f * ZoomSpeed;
|
||||
SpringArmComponent->TargetArmLength = FMath::Clamp(SpringArmComponent->TargetArmLength, MinArmLength, MaxArmLength);
|
||||
}
|
||||
|
||||
void ACameraPawn::CameraRotate(const FInputActionValue& Value)
|
||||
{
|
||||
auto f = Value.Get<float>();
|
||||
FRotator r = FRotator(0.0f, f * 2.0f, 0.0f);
|
||||
FRotator r = FRotator(0.0f, f * RotateSpeed, 0.0f);
|
||||
AddActorWorldRotation(r);
|
||||
}
|
||||
|
||||
@@ -27,12 +27,12 @@ void ACameraPawn::CameraMove(const FInputActionValue& Value)
|
||||
auto r = GetActorRightVector();
|
||||
auto f = r.Cross(FVector::UpVector);
|
||||
f.Normalize();
|
||||
SetActorLocation(GetActorLocation() + f * f2d.X * 10.0f + r * f2d.Y * 10.0f);
|
||||
SetActorLocation(GetActorLocation() + f * f2d.X * MoveSpeed + r * f2d.Y * MoveSpeed);
|
||||
}
|
||||
|
||||
void ACameraPawn::CameraReset(const FInputActionValue& Value)
|
||||
{
|
||||
SpringArmComponent->TargetArmLength = 1200.0f;
|
||||
SpringArmComponent->TargetArmLength = InitialArmLength;
|
||||
SetActorRotation(InitialRotation);
|
||||
SetActorRelativeLocation(FVector::ZeroVector);
|
||||
}
|
||||
@@ -46,8 +46,8 @@ ACameraPawn::ACameraPawn()
|
||||
// 初始化 SpringArmComponent 和 CameraComponent
|
||||
SpringArmComponent = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArmComponent"));
|
||||
SpringArmComponent->SetupAttachment(RootComponent);
|
||||
SpringArmComponent->TargetArmLength = 1200.f;
|
||||
SpringArmComponent->bUsePawnControlRotation = true;
|
||||
SpringArmComponent->TargetArmLength = InitialArmLength;
|
||||
SpringArmComponent->bUsePawnControlRotation = true;// TODO: 何意味?
|
||||
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
|
||||
CameraComponent->SetupAttachment(SpringArmComponent, USpringArmComponent::SocketName);
|
||||
|
||||
|
||||
@@ -16,10 +16,23 @@ public:
|
||||
class USpringArmComponent* SpringArmComponent;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
|
||||
class UCameraComponent* CameraComponent;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
|
||||
UPROPERTY(VisibleInstanceOnly, BlueprintReadOnly, Category = "Camera")
|
||||
APawn* FollowTarget;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Camera")
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
FRotator InitialRotation = FRotator(-60.0f, 0.0f, 0.0f);
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
float InitialArmLength = 1200.0f;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
float RotateSpeed = 2.0f;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
float ZoomSpeed =10.0f;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
float MoveSpeed = 10.0f;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
float MaxArmLength = 3000.0f;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Config")
|
||||
float MinArmLength = 300.0f;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Camera")
|
||||
void CameraZoom(const FInputActionValue& Value);
|
||||
|
||||
Reference in New Issue
Block a user