Procedural aim-down-sights results in improper translation

I’m trying to develop a procedural aim-down-sights system that will use IK to move the player’s hand to a location such that the sight of any weapon (determined by a “Sight” socket on each weapon) is aligned with the player’s camera.

To do this, I tried to get the camera’s transform and modify it by a small offset so the desired location is a little bit behind the sight, not right inside of it. Then, I tried to get the difference between the “Sight” socket and the bone that the weapon itself is attached to, i.e. the ik_hand_gun bone, which is the bone that will be moved to move the weapon.

When I do all of this, I get this result (ignore any movement from the visible hands; none of this code affects them yet).

I’m hoping someone can help me figure out what’s going wrong here? Here’s some screenshots of the relevant scripting:

If it’s not obvious, I’m still learning the animation system and am not super proficient with it. Thanks in advance for any help!

Wow, I’m a dunce. There’s nothing wrong with this code. My “Sights Mesh” was just wrong and I somehow didn’t notice. When I fixed it, everything worked as intended.

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