How to attach a Static mesh to a Skeletal mesh? C++

HI, I want to do something like this you see in this blueprint but I don’t know the syntax for engine 4.20, I searched on the internet and I don’t find any working answer.

Target->AttachToComponent(Parent, FAttachmentTransformRules::SnapToTargetNotIncludingScale, FName(TEXT("SocketName")));

Replace the Target and Parent and SocketName
Hope it helps, cheers!


Thank You very much Sir for the reply, Really appreciate it, and how to set the transforms SnapToTarget ?

Target->K2_AttachToComponent(Parent, FName(TEXT("SocketName")), Rule::Target, Rule::World, Rule::Relative, true);

Replace Rule --> EAttachmentRule
Replace Target --> SnapToTarget

Hope it helps you, cheers!


FireFlash->K2_AttachToComponent(SkeletalMesh, FName(TEXT("Socket_Muzzle")), EAttachmentRule::SnapToTarget, EAttachmentRule::KeepWorld, EAttachmentRule::KeepRelative, true);

Thank You Sir very very much, You just solved my Issue :slight_smile:

not at all, just glad for my existence to help others )