I've rigged up a basic humanoid character which holds a gun, and I'm working on an animation that sweeps the gun aim from a downward angle to an upward angle, which we'll then interpolate in-game to accomplish targeted vertical aiming. Each arm consists of three bones: upper arm (rotation at the shoulder), lower arm (rotation at the elbow) and hand (rotation at the wrist). We have an IK constraint for the upper and lower arms which we can use to easily position the hand at the appropriate point on the gun. The arm portion of the hierarchy basically looks like this:
gun
torso
upper arm (first IK-constrained bone)
lower arm (second IK-constrained bone)
hand
This aim animation will be layered on top of a looping full-body idle animation (just your basic "subtle breathing" type of thing). The gun sits at the root, rather than being parented to the hand, because we need it to be stable for the aim; if we parent it to the hand, it bounces around because of the full-body idle. The goal here is to have our gun at a stable transform for any given aim pose, and use the IK constraints (which are animated in the aim) to ensure the hands stay attached to the correct grip points on the gun throughout the entirety of the idle.
This... mostly works. Here's the current result:
Loading Image
You can see that the hands are positioned properly, but their rotation is wrong (non-stable). There's a rotation manually keyed on each hand bone to align it properly, which works fine in the editor because there's no idle playing underneath. Once the idle is added, the final rotation at the end of the IK chain (i.e. at the tip of the lower arm bone) is changing over time, since the idle moves the torso around a little bit and that's forcing the IK chain to re-evaluate in turn. The rotation I've keyed on the hand is just adding on to whatever rotation comes out the end of the IK chain.
I'd like to be able to lock the rotation (but not the position) of the hand bone, in world space, regardless of what the IK above it is doing. So like, if the rotation keyed on the hand is 90' world, I want the final result to be 90' world regardless of whether the end of the IK chain comes out with 0' rotation, or 45' rotation, or 137.45' rotation, or whatever.
Is this possible? Or is there another approach I should be taking for this?