From 42f86bc2f2ff9632f96405b941621a8d4d8f5c83 Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Sun, 12 May 2024 17:21:53 +0100 Subject: [PATCH] Bugfix Ammo Get's Reset on Weapon Swap --- .../Source/EndlessVendetta/EndlessVendettaCharacter.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index e7316d1a..2c109e5f 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -536,6 +536,10 @@ void AEndlessVendettaCharacter::EquipPrimary() GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Green, TEXT("non ifstatement code running")); //PrimaryWeaponActor->AttachToComponent(FirstPersonArms, AttachmentRules, FName("GripPoint")); HeldWeapon->SetChildActorClass(PrimaryWeaponClass); + if (PrimaryWeaponClass == PrimaryWeaponActor->GetClass()) + { + Cast(HeldWeapon->GetChildActor())->currentAmmoCount = Cast(PrimaryWeaponActor)->currentAmmoCount; + } PrimaryWeaponActor = HeldWeapon->GetChildActor(); PrimaryWeapon = Cast(PrimaryWeaponActor); PrimaryWeapon->SetActorHiddenInGame(false); @@ -600,6 +604,10 @@ void AEndlessVendettaCharacter::EquipSecondary() if (SecondaryWeaponClass != nullptr) { HeldWeapon->SetChildActorClass(SecondaryWeaponClass); + if (SecondaryWeaponClass == SecondaryWeaponActor->GetClass()) + { + Cast(HeldWeapon->GetChildActor())->currentAmmoCount = Cast(SecondaryWeaponActor)->currentAmmoCount; + } SecondaryWeaponActor = HeldWeapon->GetChildActor(); SecondaryWeapon = Cast(SecondaryWeaponActor); SecondaryWeapon->SetActorHiddenInGame(false);