Re-Worked Workbench code to use sockets instead of mesh loc
This commit is contained in:
parent
57c55fb762
commit
e3af853bdd
@ -257,11 +257,18 @@ 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"));
|
||||||
FTransform emptytransform;
|
FTransform emptytransform;
|
||||||
UActorComponent* SilencerComponent = AddComponentByClass(USilencerAttachmentClass::StaticClass(), true, emptytransform, false);
|
UActorComponent* SilencerComponent = AddComponentByClass(USilencerAttachmentClass::StaticClass(), true, emptytransform, false);
|
||||||
Cast<USilencerAttachmentClass>(SilencerComponent)->AttachToComponent(RootComponent, FAttachmentTransformRules::SnapToTargetIncludingScale);
|
UStaticMeshComponent* SilencerMeshComponent = Cast<UStaticMeshComponent>(AddComponentByClass(UStaticMeshComponent::StaticClass(), true, emptytransform, false));
|
||||||
TArray<UActorComponent*> SilencerMeshSocketArray (GetComponentsByTag(UStaticMeshComponent::StaticClass(), FName("SilencerMeshSocket")));
|
SilencerMeshComponent->SetStaticMesh(SilencerMesh);
|
||||||
Cast<UStaticMeshComponent>(SilencerMeshSocketArray[0])->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