From 64f17d7835829352ed77f2fe81e1ab03a5d79fda Mon Sep 17 00:00:00 2001 From: MH261677 Date: Tue, 6 Feb 2024 11:57:25 +0000 Subject: [PATCH] Made guns stay onto player but attach below the legs --- .../Source/EndlessVendetta/EndlessVendettaCharacter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index e61e068f..d8b4f99e 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -361,8 +361,9 @@ void AEndlessVendettaCharacter::EquipPrimary() if (IsValid(PrimaryWeapon)) { PrimaryWeapon->DetachFromActor(DetatchRules); - PrimaryWeapon->SetActorLocation(FVector(0, 0, 0), false, nullptr, ETeleportType::None); + PrimaryWeapon->AttachToComponent(Mesh1P, AttachmentRules, FName("UnEquipGunSocket")); PrimaryWeapon->SetActorHiddenInGame(true); + PrimaryWeapon->SetActorEnableCollision(false); this->GetFirstPersonCameraComponent()->SetFieldOfView(90); UE_LOG(LogTemp, Warning, TEXT("Primary Weapon Is Hidden: %hhd"), PrimaryWeapon->IsHidden()); PrimaryWeapon = nullptr; @@ -414,9 +415,9 @@ void AEndlessVendettaCharacter::EquipSecondary() if (bIsReloading) return; if (IsValid(SecondaryWeapon)) { - SecondaryWeapon->DetachFromActor(DetatchRules); - SecondaryWeapon->SetActorLocation(FVector(0, 0, 0), false, nullptr, ETeleportType::None); + SecondaryWeapon->AttachToComponent(Mesh1P, AttachmentRules, FName("UnEquipGunSocket")); SecondaryWeapon->SetActorHiddenInGame(true); + SecondaryWeapon->SetActorEnableCollision(false); this->GetFirstPersonCameraComponent()->SetFieldOfView(90); UE_LOG(LogTemp, Warning, TEXT("Secondary Weapon Is Hidden: %hhd"), SecondaryWeapon->IsHidden()); SecondaryWeapon = nullptr;