diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 28ba681..ee684d6 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -72,6 +72,8 @@ void APlayerCharacter::BeginPlay() DefaultMovementSpeed = GetCharacterMovement()->MaxWalkSpeed; + AimSensitivity = DefaultAimSensitivity; + if (!this->ActorHasTag(FName("Player"))) { this->Tags.Add(FName("Player")); @@ -187,8 +189,8 @@ void APlayerCharacter::LookCallback(const FInputActionInstance& Instance) if (vec2.Size() != 0.0f) { - AddControllerYawInput(vec2.X * 45.0f * GetWorld()->GetDeltaSeconds()); - AddControllerPitchInput((vec2.Y * (-1.0f)) * 45.0f * GetWorld()->GetDeltaSeconds()); + AddControllerYawInput(vec2.X * AimSensitivity * GetWorld()->GetDeltaSeconds()); + AddControllerPitchInput((vec2.Y * (-1.0f)) * AimSensitivity * GetWorld()->GetDeltaSeconds()); } } @@ -415,6 +417,8 @@ void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& In SetMovementSpeed(); + AimSensitivity = DefaultAimSensitivity * ADSAimSensitivityMultiplier; + FLatentActionInfo LatentActionInfo; LatentActionInfo.CallbackTarget = this; CameraComponent->AttachToComponent(CameraADSSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform, @@ -431,6 +435,8 @@ void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Inst SetMovementSpeed(); + AimSensitivity = DefaultAimSensitivity; + FLatentActionInfo LatentActionInfo; LatentActionInfo.CallbackTarget = this; CameraComponent->AttachToComponent(CameraSpringArmComponent, FAttachmentTransformRules::KeepWorldTransform, diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index d579454..9b23bcb 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -68,9 +68,15 @@ protected: UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) float ADSSpeedMultiplier = 0.5f; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + float ADSAimSensitivityMultiplier = 0.5f; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) float CameraBlendTime = 0.1f; + UPROPERTY(EditDefaultsOnly, BlueprintReadWrite) + float DefaultAimSensitivity = 45.0f; + private: UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (AllowPrivateAccess = "true")) USpringArmComponent* CameraSpringArmComponent = nullptr; @@ -97,6 +103,8 @@ private: bool IsSpriting = false; bool IsADS = false; + + float AimSensitivity; public: // Sets default values for this character's properties