Is there any way to get/set the position/rotation of a socket?

I want to solve a problem that occurs when attaching different weapons…

Because not all weapons have the same size, initial rotation ect.

So when attaching the weapon sometimes it happens that it is not in the perfect position.

I think that a simple way to solve this problem could be to use two sockets. Two on the weapon, and one in each character’s hand.

So after attaching the weapon to the character I could use the right hand socket to adjust the height of the weapon and the left hand socket to adjust the rotation of the weapon.

But for that I need to get/set the relative position/rotation of the sockets.

Is there a function that provides this data?


NOTE:


If you know of a better or easier way to do that, please let me know.

Thank you so much!!

Don’t know about modifying socket positions, but you can certainly attach weapon to character hand socket, and offset the weapon by the inverse of its handle socket position so that the handle fits right into the hand.

Something like this :

// USkeletalMesh* WeaponMesh
// USkeletalMesh* CharacterMesh
auto& WeaponSocket = WeaponMesh->GetSocketTransform("Handle", RTS_Component);
WeaponMesh->SetRelativeTransform(WeaponSocket.Inverse());
WeaponMesh->AttachToComponent(CharacterMesh, FAttachmentTransformRules::KeepRelativeTransform, "RightHand");
1 Like

This works perfect!!
Thank you very much for your help!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.