Bugfix Able to Pickup Rifle Weapon & Switch w/ Secondary

This commit is contained in:
Philip W 2024-05-10 19:51:09 +01:00
parent 2c088ffb02
commit 2b9ca4c312
6 changed files with 23 additions and 17 deletions

Binary file not shown.

View File

@ -487,10 +487,10 @@ void AEndlessVendettaCharacter::EquipPrimary()
if (bIsReloading) return;
if (IsValid(PrimaryWeapon))
{
TempUnequippedPrimary();
//TempUnequippedPrimary();
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("IsPrimaryWeapon valid check running"));
PrimaryWeapon->DetachFromActor(DetatchRules);
PrimaryWeapon->AttachToComponent(FirstPersonArms, AttachmentRules, FName("UnEquipGunSocket"));
//PrimaryWeapon->DetachFromActor(DetatchRules);
//PrimaryWeapon->AttachToComponent(FirstPersonArms, AttachmentRules, FName("UnEquipGunSocket"));
PrimaryWeapon->SetActorHiddenInGame(true);
PrimaryWeapon->SetActorEnableCollision(false);
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
@ -520,9 +520,11 @@ void AEndlessVendettaCharacter::EquipPrimary()
if (!bIsPrimaryWeaponCreated)
{
PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
//PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
HeldWeapon->SetChildActorClass(PrimaryWeaponClass);
PrimaryWeaponActor = HeldWeapon->GetChildActor();
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("Spawning weapon"));
PrimaryWeaponActor->AttachToComponent(FirstPersonArms, AttachmentRules, FName("GripPoint"));
//PrimaryWeaponActor->AttachToComponent(FirstPersonArms, AttachmentRules, FName("GripPoint"));
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
PrimaryWeapon->SetActorHiddenInGame(false);
PrimaryWeapon->SetActorEnableCollision(false);
@ -535,15 +537,17 @@ void AEndlessVendettaCharacter::EquipPrimary()
if (PrimaryWeaponClass != nullptr)
{
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Green, TEXT("non ifstatement code running"));
PrimaryWeaponActor->AttachToComponent(FirstPersonArms, AttachmentRules, FName("GripPoint"));
//PrimaryWeaponActor->AttachToComponent(FirstPersonArms, AttachmentRules, FName("GripPoint"));
HeldWeapon->SetChildActorClass(PrimaryWeaponClass);
PrimaryWeaponActor = HeldWeapon->GetChildActor();
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
PrimaryWeapon->SetActorHiddenInGame(false);
PrimaryWeapon->SetActorEnableCollision(false);
GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle);
//GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle);
bIsCurrentlyHoldingWeapon = true;
bHasRifle = true;
SetOverlayState(EOverlayState::AssaultRifle);
TempEquippedPrimary();
//TempEquippedPrimary();
EquippedWeapon.Broadcast();
}
}
@ -598,6 +602,8 @@ void AEndlessVendettaCharacter::EquipSecondary()
}
if (SecondaryWeaponClass != nullptr)
{
HeldWeapon->SetChildActorClass(SecondaryWeaponClass);
SecondaryWeaponActor = HeldWeapon->GetChildActor();
SecondaryWeapon = Cast<ABaseWeaponClass>(SecondaryWeaponActor);
SecondaryWeapon->SetActorHiddenInGame(false);
bIsCurrentlyHoldingWeapon = true;