Problem with static mesh to socket attachment in C++

Hey guys.

I faced a problem with attachment of my static weapon mesh to socket on the character’s arms skeleton. It looks fine when I add mesh for preview:

But then I attach my mesh within BeginPlay function by code:

if (EquippedWeapon)
	FAttachmentTransformRules rules(EAttachmentRule::SnapToTarget, true);
	EquippedWeapon->WeaponMesh->AttachToComponent(FirstPersonMesh, rules, TEXT("b_WeaponRightSocket"));

And get something like this:

Weapon mesh still depends from arms bones position though, so if I change arms pose, mesh will change the position. But this dependence is totally wrong.

I’m sure I doing something wrong since I’m newbie in UE4 but I wonder if someone can direct me to the right way with this issue.


Well, my mistake was just in socket naming. It seems that “b_” prefix hardly used for bones only. So I’ve renamed my socket to “WeaponSocket” and it works fine now.