From 6960a94be5116a7ee8e3a80f52ee57070dbe8086 Mon Sep 17 00:00:00 2001 From: Kingsmedia Date: Tue, 10 May 2022 00:45:30 +0200 Subject: [PATCH] 118 - Auto Reload --- Source/Blaster/Components/CombatComponent.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Source/Blaster/Components/CombatComponent.cpp b/Source/Blaster/Components/CombatComponent.cpp index bc6b062..6cfba8e 100644 --- a/Source/Blaster/Components/CombatComponent.cpp +++ b/Source/Blaster/Components/CombatComponent.cpp @@ -213,6 +213,10 @@ void UCombatComponent::FireTimerFinished() { Fire(); } + if (EquippedWeapon->IsEmpty()) + { + Reload(); + } } bool UCombatComponent::CanFire() @@ -330,6 +334,11 @@ void UCombatComponent::EquipWeapon(AWeapon* WeaponToEquip) { UGameplayStatics::PlaySoundAtLocation(this, EquippedWeapon->EquipSound, Character->GetActorLocation()); } + + if (EquippedWeapon->IsEmpty()) + { + Reload(); + } Character->GetCharacterMovement()->bOrientRotationToMovement = false; Character->bUseControllerRotationYaw = true; }