Fixed Primary Weapon not replacing when picking up new primary bug

This commit is contained in:
MH261677 2024-02-12 17:53:21 +00:00 committed by PHILIP WHITE
parent d2de6adb98
commit 75df1a6bb1
3 changed files with 21 additions and 5 deletions

View File

@ -9,6 +9,7 @@
<component name="ChangeListManager">
<list default="true" id="dfa3053d-1d51-4dad-9270-4c17e086f627" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/EndlessVendetta.sln.DotSettings.user" beforeDir="false" afterPath="$PROJECT_DIR$/EndlessVendetta.sln.DotSettings.user" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -47,9 +48,9 @@
},
"keyToStringList": {
"rider.external.source.directories": [
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache",
"C:\\Users\\Rafal\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache",
"C:\\Users\\Rafal\\AppData\\Local\\Symbols\\src"
"C:\\Users\\mhara\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache",
"C:\\Users\\mhara\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache",
"C:\\Users\\mhara\\AppData\\Local\\Symbols\\src"
]
}
}]]></component>
@ -128,6 +129,7 @@
<workItem from="1706972179014" duration="11096000" />
<workItem from="1707046474738" duration="8878000" />
<workItem from="1707103463352" duration="6662000" />
<workItem from="1707755232377" duration="4194000" />
</task>
<servers />
</component>

View File

@ -1,5 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\Rafal\AppData\Local\JetBrains\Rider2023.3\resharper-host\temp\Rider\vAny\CoverageData\_EndlessVendetta.-1253833435\Snapshot\snapshot.utdcvr</s:String>
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=aba8233e_002D1c76_002D499a_002Db1de_002D7423eeed41c5/@EntryIndexedValue">&lt;SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"&gt;&#xD;
&lt;Solution /&gt;&#xD;
&lt;/SessionState&gt;</s:String></wpf:ResourceDictionary>

View File

@ -364,6 +364,7 @@ void AEndlessVendettaCharacter::EquipPrimary()
PrimaryWeapon->AttachToComponent(Mesh1P, AttachmentRules, FName("UnEquipGunSocket"));
PrimaryWeapon->SetActorHiddenInGame(true);
PrimaryWeapon->SetActorEnableCollision(false);
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("Weapon Removing because validated"));
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
UE_LOG(LogTemp, Warning, TEXT("Primary Weapon Is Hidden: %hhd"), PrimaryWeapon->IsHidden());
PrimaryWeapon = nullptr;
@ -387,6 +388,7 @@ void AEndlessVendettaCharacter::EquipPrimary()
if (!bIsPrimaryWeaponCreated)
{
PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("Spawning weapon"));
PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
PrimaryWeapon->SetActorHiddenInGame(false);
@ -394,11 +396,14 @@ void AEndlessVendettaCharacter::EquipPrimary()
bIsPrimaryWeaponCreated = true;
}
}
//For when you already have all your weapons and ur switching with 1 and 2 or when your picking up a weapon with a weapon in hand
PrimaryWeaponActor->AttachToComponent(Mesh1P, AttachmentRules, FName("GripPoint"));
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Green, TEXT("non ifstatement code running"));
PrimaryWeapon = Cast<ABaseWeaponClass>(PrimaryWeaponActor);
PrimaryWeapon->SetActorHiddenInGame(false);
GetWorldTimerManager().ClearTimer(PrimaryWeapon->reloadTimerHandle);
bIsCurrentlyHoldingWeapon = true;
bHasRifle = true;
}
void AEndlessVendettaCharacter::EquipSecondary()
@ -454,14 +459,23 @@ void AEndlessVendettaCharacter::EquipSecondary()
void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
{
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
FDetachmentTransformRules DetatchRules(EDetachmentRule::KeepWorld, false);
FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
if (Outhit->ActorHasTag("PrimaryWeapon"))
{
PrimaryWeaponClass = Outhit->GetClass();
if (IsValid(PrimaryWeapon))
{
if(bIsCurrentlyHoldingWeapon)
{
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, TEXT("Player is currently holding weapon"));
PrimaryWeaponActor = GetWorld()->SpawnActor<AActor>(PrimaryWeaponClass, spawnParams);
}
EquipPrimary();
}
bIsWeaponPickedUp = true;
PrimaryWeaponClass = Outhit->GetClass();
UEVGameInstance* GI = Cast<UEVGameInstance>(GetGameInstance());
if (IsValid(GI->MainSaveGameInstanceRef))
{