Reworked Attachment spawning code to be more universal

This commit is contained in:
MH261677 2024-02-01 14:24:31 +00:00
parent 3990cefbc0
commit 9329454318
8 changed files with 61 additions and 44 deletions

View File

@ -9,6 +9,13 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="8acc2658-cb31-4c49-857f-282cfee74640" name="Changes" comment=""> <list default="true" id="8acc2658-cb31-4c49-857f-282cfee74640" 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$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FPWeapon/Mesh/SK_FPGun_Skeleton.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_ARTEST1.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BaseWeapons/AssaultRifles/BP_ARTEST1.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BaseWeapons/BP_BaseWeapon.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/Shapes/TempSilencer.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Shapes/TempSilencer.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/__ExternalActors__/Levels/DoorTestLevel/9/PG/AISD2CY0WTWKV1BJDYTYJ3.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/__ExternalActors__/Levels/DoorTestLevel/9/PG/AISD2CY0WTWKV1BJDYTYJ3.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/WeaponSystem/BaseWeaponClass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Workbench&amp;Attachments/SilencerAttachmentClass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Workbench&amp;Attachments/SilencerAttachmentClass.cpp" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -30,28 +37,28 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"C++ Project.EndlessVendetta.executor": "Run", &quot;C++ Project.EndlessVendetta.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.OpenProjectViewOnStart": "true", &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"git-widget-placeholder": "dev", &quot;git-widget-placeholder&quot;: &quot;attachment-bug-fix&quot;,
"ignore.virus.scanning.warn.message": "true", &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}, },
"keyToStringList": { &quot;keyToStringList&quot;: {
"rider.external.source.directories": [ &quot;rider.external.source.directories&quot;: [
"C:\\Users\\mhara\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache", &quot;C:\\Users\\mhara\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\DecompilerCache&quot;,
"C:\\Users\\mhara\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache", &quot;C:\\Users\\mhara\\AppData\\Roaming\\JetBrains\\Rider2023.3\\resharper-host\\SourcesCache&quot;,
"C:\\Users\\mhara\\AppData\\Local\\Symbols\\src" &quot;C:\\Users\\mhara\\AppData\\Local\\Symbols\\src&quot;
] ]
} }
}]]></component> }</component>
<component name="RunManager"> <component name="RunManager">
<configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project"> <configuration name="EndlessVendetta" type="CppProject" factoryName="C++ Project">
<configuration_1> <configuration_1>
@ -127,6 +134,9 @@
<workItem from="1705756768038" duration="3821000" /> <workItem from="1705756768038" duration="3821000" />
<workItem from="1705856571902" duration="3954000" /> <workItem from="1705856571902" duration="3954000" />
<workItem from="1706110241756" duration="1092000" /> <workItem from="1706110241756" duration="1092000" />
<workItem from="1706705451486" duration="5218000" />
<workItem from="1706727398145" duration="597000" />
<workItem from="1706790490396" duration="6139000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:e1a0785430701e8ad4da18841226e2e18dd72d825c6a10cf28e7d73f1216ed28 oid sha256:8924c723b3b8eaf0a1a580f215de2a547d9118851c617ad590199910fa2f48c9
size 9013 size 9020

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:61c0b03ac13ff095d5e52f5551a54cadb54e669e33e5a6a1ee4f8e4e233e50f2 oid sha256:cb6b37e3900f88fd3a4a94643d255ddb765f6cacefc1b8adc92c5fb97e7393a8
size 26923 size 28238

View File

@ -258,19 +258,28 @@ void ABaseWeaponClass::InteractPrompt()
void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh) void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
{ {
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP SILENCER ATTACHMENTS")); GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP SILENCER ATTACHMENTS"));
FTransform emptytransform; FTransform EmptyTransform;
UActorComponent* SilencerComponent = AddComponentByClass(USilencerAttachmentClass::StaticClass(), true, emptytransform, false);
UStaticMeshComponent* SilencerMeshComponent = Cast<UStaticMeshComponent>(AddComponentByClass(UStaticMeshComponent::StaticClass(), true, emptytransform, false));
SilencerMeshComponent->SetStaticMesh(SilencerMesh);
SilencerMeshComponent->AttachToComponent(Cast<USceneComponent>(GetComponentByClass(USkeletalMeshComponent::StaticClass())), FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("SilencerMeshSocket")));
Cast<USilencerAttachmentClass>(SilencerComponent)->AttachToComponent(SilencerMeshComponent, FAttachmentTransformRules::SnapToTargetIncludingScale);
FTransform SilencerSocketTransform = SilencerMeshComponent->GetSocketTransform(FName(TEXT("SilencerMeshSocket")), RTS_Component);
FRotator SilencerSocketRotation = SilencerMeshComponent->GetSocketRotation(FName(TEXT("SilencerMeshSocket")));
SilencerMeshComponent->SetRelativeTransform(SilencerSocketTransform);
SilencerMeshComponent->SetRelativeRotation(this->GetActorRotation());
USceneComponent* SilencerAttachmentClass = Cast<USceneComponent>(AddComponentByClass(USilencerAttachmentClass::StaticClass(), false, EmptyTransform, false));
USkeletalMeshComponent* WeaponSkeletonMesh = FindComponentByClass<USkeletalMeshComponent>();
if (IsValid(SilencerAttachmentClass))
{
if (IsValid(WeaponSkeletonMesh))
{
SilencerAttachmentClass->AttachToComponent(WeaponSkeletonMesh, FAttachmentTransformRules::SnapToTargetIncludingScale, FName(TEXT("SilencerSocketMesh")));
UE_LOG(LogTemp, Display, TEXT("All Attachment is valid"));
//this makes it showup in editor for better debugging
SilencerAttachmentClass->CreationMethod = EComponentCreationMethod::Instance;
SilencerAttachmentClass->RegisterComponent();
UStaticMeshComponent* StaticMeshComp = NewObject<UStaticMeshComponent>(SilencerAttachmentClass, UStaticMeshComponent::StaticClass());
if (IsValid(StaticMeshComp))
{
StaticMeshComp->AttachToComponent(SilencerAttachmentClass, FAttachmentTransformRules::SnapToTargetIncludingScale);
StaticMeshComp->SetStaticMesh(SilencerMesh);
StaticMeshComp->CreationMethod = EComponentCreationMethod::Instance;
StaticMeshComp->RegisterComponent();
}
}
}
} }

View File

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