From c5bf15f6fde72763f07e1f496c03b348978c961e Mon Sep 17 00:00:00 2001 From: MARCEL HARA Date: Mon, 23 Oct 2023 11:46:23 +0100 Subject: [PATCH] Fixed not being able to fire after switching weapons when reloading --- .../Source/EndlessVendetta/EndlessVendettaCharacter.cpp | 5 ++++- .../Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 656279bf..3cfc910d 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -223,6 +223,7 @@ void AEndlessVendettaCharacter::ToggleCombat() //When 1 is pressed it calls EquipPrimary void AEndlessVendettaCharacter::EquipPrimary() { + if (bIsReloading) return; if (IsValid(PrimaryWeapon)) { PrimaryWeapon->Destroy(); @@ -249,11 +250,12 @@ void AEndlessVendettaCharacter::EquipPrimary() //Changing PrimaryWeaponActor to ABaseWeaponClass type instead of actor and storing it into PrimaryWeapon which is a ABaseClass Object //We do this because we need to check if PrimaryWeapon is equipped and we want primaryweapon to be ABaseWeapon type and not a generic AActor PrimaryWeapon = Cast(PrimaryWeaponActor); - + GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle); } void AEndlessVendettaCharacter::EquipSecondary() { + if (bIsReloading) return; if (IsValid(SecondaryWeapon)) { SecondaryWeapon->Destroy(); @@ -277,6 +279,7 @@ void AEndlessVendettaCharacter::EquipSecondary() AActor* SecondaryWeaponActor = GetWorld()->SpawnActor(SecondaryWeaponClass, spawnParams); SecondaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint")); SecondaryWeapon = Cast(SecondaryWeaponActor); + GetWorldTimerManager().ClearTimer(SecondaryWeapon->reloadTimerHandle); } void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit) diff --git a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h index caed9bb1..36de56ca 100644 --- a/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h +++ b/EndlessVendetta/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.h @@ -54,6 +54,7 @@ public: // Called every frame virtual void Tick(float DeltaTime) override; void ReloadTimer(); + UPROPERTY(EditAnywhere, BlueprintReadWrite) FString WeaponName;