Disallow Sprinting and Aiming Downsights at the same time

This commit is contained in:
baz 2024-03-05 15:32:32 +00:00
parent 23db1dff33
commit 91f2befa71
1 changed files with 20 additions and 8 deletions

View File

@ -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<FHitResult>* hits)
@ -518,6 +520,11 @@ void APlayerCharacter::WeaponSwitchingCallback(const FInputActionInstance& Insta
void APlayerCharacter::BeginAimDownSightsCallback(const FInputActionInstance& Instance)
{
if (IsSprinting)
{
return;
}
IsADS = true;
if (UNakatomiCMC* cmc = GetCharacterMovementComponent())
@ -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())