From 91f2befa712c858ec3e3a932f84b0adcca0351bd Mon Sep 17 00:00:00 2001 From: baz Date: Tue, 5 Mar 2024 15:32:32 +0000 Subject: [PATCH] Disallow Sprinting and Aiming Downsights at the same time --- Source/Nakatomi/PlayerCharacter.cpp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index 3846d19..5ef8455 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -298,22 +298,24 @@ void APlayerCharacter::QuitCallback(const FInputActionInstance& Instance) void APlayerCharacter::SetSprintingCallback(const FInputActionInstance& Instance) { - if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) + UNakatomiCMC* cmc = GetCharacterMovementComponent(); + + if (!IsADS && cmc) { cmc->EnableSprint(); + IsSprinting = true; } - - IsSprinting = true; } void APlayerCharacter::SetWalkingCallback(const FInputActionInstance& Instance) { - if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) + UNakatomiCMC* cmc = GetCharacterMovementComponent(); + + if (!IsADS && cmc) { cmc->DisableSprint(); + IsSprinting = false; } - - IsSprinting = false; } void APlayerCharacter::CalculateHits(TArray* hits) @@ -518,13 +520,18 @@ void APlayerCharacter::WeaponSwitchingCallback(const FInputActionInstance& Insta void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& Instance) { - IsADS = true; + if (IsSprinting) + { + return; + } + IsADS = true; + if (UNakatomiCMC* cmc = GetCharacterMovementComponent()) { cmc->EnableAds(); } - + AimSensitivity = DefaultAimSensitivity * ADSAimSensitivityMultiplier; if (CurrentWeapon) @@ -544,6 +551,11 @@ void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& In void APlayerCharacter::EndAimDownSightsCallback(const FInputActionInstance& Instance) { + if (IsSprinting) + { + return; + } + IsADS = false; if (UNakatomiCMC* cmc = GetCharacterMovementComponent())