Bugfix Able to Equip Rifle Before Pickup

This commit is contained in:
Philip W 2023-11-27 01:10:36 +00:00
parent 7aecf2a69c
commit 05679cc334
4 changed files with 18 additions and 17 deletions

Binary file not shown.

Binary file not shown.

View File

@ -306,17 +306,18 @@ void AEndlessVendettaCharacter::EquipPrimary()
if (GadgetManager->IsValidCombatGadget() && GadgetManager->IsCombatEquipped() && !GadgetManager->TryToUnequipCombat()) return;
bHasRifle = true;
if(!bIsPrimaryWeaponCreated)
{
//Creating a new actor object called PrimaryWeapon that is based off primaryweaponClass
//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
PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
PrimaryWeapon->SetActorHiddenInGame(false);
bIsPrimaryWeaponCreated = true;
}
// if(!bIsPrimaryWeaponCreated)
// {
// //Creating a new actor object called PrimaryWeapon that is based off primaryweaponClass
// //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
// PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
// PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
// PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
// PrimaryWeapon->SetActorHiddenInGame(false);
// bIsPrimaryWeaponCreated = true;
// }
if (!IsValid(PrimaryWeaponActor)) return;
PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
PrimaryWeapon->SetActorHiddenInGame(false);