Fixed extended mag attachement code not working

This commit is contained in:
MH261677 2024-03-19 13:51:30 +00:00
parent dd4cb95d1c
commit cd8f414b03
3 changed files with 7 additions and 5 deletions

Binary file not shown.

View File

@ -13,6 +13,7 @@
#include <EndlessVendetta/EndlessVendettaGameMode.h>
#include "EndlessVendetta/BountySystem/ControlsTraining/TargetDummy.h"
#include "EndlessVendetta/Workbench&Attachments/ExtendedMagAttachmentClass.h"
#include "EndlessVendetta/Workbench&Attachments/SilencerAttachmentClass.h"
@ -319,7 +320,7 @@ void ABaseWeaponClass::SetupExtendedMagAttachment(UStaticMesh* ExtendedMagMesh)
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP EXTENDEDMAG ATTACHMENTS"));
FTransform EmptyTransform;
USceneComponent* ExtendedMagAttachmentClass = Cast<USceneComponent>(AddComponentByClass(USilencerAttachmentClass::StaticClass(), false, EmptyTransform, false));
USceneComponent* ExtendedMagAttachmentClass = Cast<USceneComponent>(AddComponentByClass(UExtendedMagAttachmentClass::StaticClass(), false, EmptyTransform, false));
ExtendedMagAttachmentClass->ComponentTags.Add(FName("AttachmentType"));
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
if (IsValid(ExtendedMagAttachmentClass))
@ -327,7 +328,7 @@ void ABaseWeaponClass::SetupExtendedMagAttachment(UStaticMesh* ExtendedMagMesh)
if (IsValid(WeaponSkeletonMesh))
{
//this handles giving the weapon the required component class/code
ExtendedMagAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("SilencerMeshSocket")));
ExtendedMagAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("ExtendedMagSocket")));
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
//this makes it showup in editor for better debugging
ExtendedMagAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
@ -338,7 +339,7 @@ void ABaseWeaponClass::SetupExtendedMagAttachment(UStaticMesh* ExtendedMagMesh)
{
StaticMeshComp->AttachToComponent(ExtendedMagAttachmentClass, FAttachmentTransformRules::SnapToTargetIncludingScale);
StaticMeshComp->SetStaticMesh(ExtendedMagMesh);
StaticMeshComp->SetRelativeRotation(FRotator(0, 90, 0));
StaticMeshComp->SetRelativeRotation(FRotator(0, 180, 0));
StaticMeshComp->SetCollisionEnabled(ECollisionEnabled::NoCollision);
//Making it show in editor for debugging
StaticMeshComp->CreationMethod = EComponentCreationMethod::Instance;

View File

@ -29,7 +29,5 @@ void UExtendedMagAttachmentClass::BeginPlay()
void UExtendedMagAttachmentClass::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}