In the previous movie, we created an elbow control for the IK arm rig
and added the ability to snap to it.
In this movie, we're going to add an FK hybrid solution to that elbow.
Start by opening the file "25-0- Character_Rigging_part25_start.mb"
or by using your own file from the previous lesson.
We already examined how certain arm motions might be difficult to accomplish
with the IK arm when the elbow is pinned.
Most notably, anything requiring precision rotations would be almost impossible.
To keep this easier on the animator,
we're going to create an FK forearm that will work with our IK arm.
That way, we'll be able to pin the arm in IK mode, and then rotate the forearm on that spot.
To start, switch the arm to FK mode.
We're going to use our existing FK arm chain as the base for creating our hybrid arm,
but we only need it from the forearm onward.
Duplicate the FK forearm and unparent the duplicate.
Switch the arm back to IK mode.
Then select the leftElbow_CTRL and turn on the "Elbow Snap" attribute
since this is how we'll typically use our new control.
Unhide the leftElbow_LOC
and then snap the duplicate FK forearm to it.
Hide the locator when you're done.
Rename the joints with an "elbow" identifier.
And parent it under the leftElbow_CTRL in the Outliner.
Now, we want to blend between using this FK joint chain
versus the usual IK joint chain when in "elbow FK mode". How do we do this?
Since we've been using blendColor nodes for all our IK/FK blending up to this point in this series,
you might be tempted to do so again here. However this time there's a complication.
The IK arm currently exists in world space.
However, the FK control is parented under the leftElbow_CTRL
and therefore exists within elbow space.
This means that if we tried to blend the hand using this position,
the arm wouldn't jump to the new control, but rather to a relative position in world space!
For this reason, we'll instead use a constraint to link the arm's IK handles
to both the leftArm_CTRL and the leftElbowHand_FK_CTRL.
First, group everything under the leftArm_CTRL into a "leftArm_IKConst_GRP".
Double check to ensure the group's pivot is at the hand joint and then unparent it.
This will break the functionality of the leftArm_CTRL temporarily.
To fix that, parent constrain this group to the leftArm_CTRL.
Next, create another parent constraint from the leftElbowHand_FK_CTRL to the IKConst_GRP.
For this constraint, you must make sure the "Maintain Offset" option is turned off
to ensure the new elbow FK chain snaps to leftArm_CTRL's position.
The arm ends up in a position that's halfway between the two controls.
To fully commit to the FK arm,
we'll manually set the parent constraint's weights in the Channel Box.
Well, it partially works.
The arm snaps to the new control, and rotates correctly, but it's upside down!
Why is this?
Again, we're dealing with a space problem.
If we compare the transform attributes of the IKConst_GRP
when in full IK and FK forearm mode, notice that they're different.
This is because the local rotation axes of both our leftArm_CTRL
and leftElbowHand_FK_CTRL aren't actually the same.
This is the reason the hand flips around.
In order to fix this, we'll have to make the spaces identical.
Note the rotation values of the IKConst_GRP when in FK forearm mode.
Return full weighting to the leftArm_CTRL and delete the parent constraint.
Temporarily unparent everything under the IKConst_GRP.
Set the rotation values to the noted values from earlier.
Now reparent all the IK handles and locators back to the group.
We'll re-create the parent constraint between the leftArm_CTRL and the IKConst_GRP,
but because we rotated the space we'll need to make sure the "Maintain Offset" option is turned on.
Now add the parent constraint between the leftElbowHand_FK_CTRL and the IKConst_GRP.
Because the spaces now match, we'll do this with the "Maintain Offset" option turned off.
Once again, the arm moves between the two controls, but this time it isn't rotated like before.
If you manually adjust the weights
you can change the control from full IK mode to the FK forearm.
Next we'd like to create a control to toggle between them.
Select the leftElbow_CTRL and create a new attribute named "FK_forearmBlend".
Set its "Minimum" to 0 and "Maximum" to 1.
Now, if we were hooking this up to a blend colors node like usual,
we'd only have to connect this attribute to its "Blender" attribute.
Unfortunately, since we're connecting two distinct parent constraint weight attributes,
instead we'll use a driven key animation.
Load the leftElbow_CTRL as the driver, and the parent constraint as driven.
Select the "FK Forearm Blend" and the two constraint weight attributes and set a key.
Set the FK Forearm Blend attribute to "1" and swap the two constraint weight values.
Set another key.
Now you can use your new attribute to blend between both modes.
Next, we'll want to control the visibility of these controls based on what mode we're in.
Start by adding a new custom attribute to the leftElbow_CTRL named "forearm_FK_visibility".
Set its Data Type to "Boolean".
Use the Connection Editor to connect this new attribute to the visibility of the FK forearm.
Then set a driven key between the FK Forearm Blend and this visibility attribute
so that the control is only visible when the blend is at a value greater than 0.
Handling the visibility of the leftArm_CTRL is going to be slightly trickier,
because we're already driving its visibility with the arm's IK/FK mode.
To do this, first group the leftArm_CTRL in a group named "leftArm_IK_vis_GRP".
Select it and the leftArm_CTRL and open Node Editor.
Show the connections.
Reroute the connection from the leftArm_settings_CTRL's "IK_Visibility" attribute
to this new group.
Delete the old connection to the leftArm_CTRL.
This frees you to set a driven key on the leftArm_CTRL's visibility
based on the "FK Forearm Blend".
Since the new group we created is strictly for managing the control's visibility,
let's lock and hide all its attributes.
While we're at it, we should also set a driven key on the leftElbow_CTRL's visibility
based the "IK Visibility" attribute of the leftArm_settings_CTRL.
Since that attribute is unavailable to us right now,
we'll have to first select the leftElbow_CTRL and open the Channel Control Editor.
In the "Nonkeyable Hidden" list, select "Visibility" and move it to the "Keyable" list.
You can now see it in the Channel Box, though it is still locked.
Go to the "Locked" tab, select "Visibility" from the "Locked" list
and move it to the list of "Non Locked" attributes. You can now use this attribute.
Then use the Set Driven Key window to set the appropriate keys
between the leftArm_settings_CTRL's "IK Visibility" attribute
and the "Visibility" of the leftElbow_CTRL.
When you're done, you can lock and hide the "Visibility" attribute again.
The only thing left to do is recreate the squash and stretch functionality on the FK forearm,
which was unfortunately broken when we duplicated the original FK forearm.
We'll do this exactly as we have before in part 23,
by using the Set Driven Key window to create driven keys
between the forearm's "Length" attribute and the hand's "Translate X" attribute.
We'll set a "Length" value of "0" to squash the forearm completely,
a value of "1" to revert it to its default scale, and any higher value to stretch it.
Remember - to achieve infinite stretch, you need to go through the Graph Editor
to change the graph's interpolation and post infinity to "Linear".
Now you can easily pose the left arm even when the elbow is pinned in IK mode.
You'll notice that the FK forearm chain has changed from blue to yellow
ever since we parented it to the leftElbow_CTRL.
We'll leave this as is, even though it's an FK control,
just to emphasize that it's actually part of the IK elbow.
This brings us to the end of the arm rig.
In the next movie, we'll begin work on the shoulder
so we can connect this arm up to the rest of the body.