Added Silencer attachment code to all weapons

This commit is contained in:
MH261677 2024-01-12 18:50:53 +00:00
parent 1939f521f8
commit 21cfa4f2c9
2 changed files with 13 additions and 13 deletions

View File

@ -12,6 +12,8 @@
#include "EndlessVendetta/AI/EnemyCharacter.h"
#include <EndlessVendetta/EndlessVendettaGameMode.h>
#include "EndlessVendetta/Workbench&Attachments/SilencerAttachmentClass.h"
// Sets default values
ABaseWeaponClass::ABaseWeaponClass()
@ -251,19 +253,14 @@ void ABaseWeaponClass::InteractPrompt()
WeaponStatsPopUp();
}
// void ABaseWeaponClass::GetOutHit(FHitResult OutHit)
// {
// if(IsValid(this))
// {
// endlessVendettaChar->PrimaryWeapon->Destroy();
// }
// if (OutHit.GetActor()->ActorHasTag(FName("AssaultRifle")))
// {
// endlessVendettaChar->EquipPrimary();
// }
// AActor* HitActor = Cast<ABaseWeaponClass>(endlessVendettaChar->PrimaryWeaponClass);
// endlessVendettaChar->PrimaryWeapon = Cast<ABaseWeaponClass>(HitActor);
// }
void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
{
FTransform emptytransform;
UActorComponent* SilencerComponent = AddComponentByClass(USilencerAttachmentClass::StaticClass(), true, emptytransform, false);
Cast<USilencerAttachmentClass>(SilencerComponent)->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetIncludingScale);
TArray<UActorComponent*> SilencerMeshSocketArray (GetComponentsByTag(UStaticMeshComponent::StaticClass(), FName("SilencerMeshSocket")));
Cast<UStaticMeshComponent>(SilencerMeshSocketArray[0])->SetStaticMesh(SilencerMesh);
}

View File

@ -176,6 +176,9 @@ public:
//void GetOutHit(FHitResult OutHit);
UFUNCTION(BlueprintCallable)
void SetupSilencerAttachment(UStaticMesh* SilencerMesh);
protected:
UArrowComponent* GunStartArrow;
bool bStopShooting = false;