Re-Worked Workbench code to use sockets instead of mesh loc
This commit is contained in:
parent
57c55fb762
commit
e3af853bdd
@ -257,13 +257,20 @@ void ABaseWeaponClass::InteractPrompt()
|
||||
|
||||
void ABaseWeaponClass::SetupSilencerAttachment(UStaticMesh* SilencerMesh)
|
||||
{
|
||||
GEngine->AddOnScreenDebugMessage(-1, 15.f, FColor::Red, TEXT("SETTING UP SILENCER ATTACHMENTS"));
|
||||
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);
|
||||
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());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user