Support

  Tips & Techniques - MOCCA

MOCCA:
IK - FK Switching
Download:
Project
Works with:
MOCCA, XL, Studio
Requires:
Version 8.1 +
 


 
IK is almost always used for animating a character's arms or legs. But, sometimes the motion that IK provides isn't what the animator wants. So the animator will manually rotate and keyframe the arm bones. This tutorial will show you how to setup an IK / FK switch for a character's arm rig so an animator can animate the arm any which way they want.

 
Step 1: Create an arm bone chain as shown using the Bone Tool (Plugins=>MOCCA=>Bone Tool). Creating the fingers for this bone chain isn't really necessary. Make sure to add a Null Bone to the top of the bone chain.

 
Step 2: Rename the bones to match the naming convention as shown. This will make things easier for reference.

 
Step 3: Since you don't want the hand to be apart of the IK solution, move this bone out of the hierarchy temporarily. Now that the bones are setup, you will need to apply IK to the chain. Select the Arm Null bone and Setup IK chain (Plugins=>MOCCA=>Setup Ik Chain).

 
Note: You might want to disable Soft IK while you are setting up the IK chain (Plugins=>MOCCA=>Use Soft IK). This might cause adverse effects on the bones before the IK is properly setup.

 
Step 4: Place the newly created Forearm.Tip Goal as a child of the Hand bone and zero out all rotation fields for the object. Move the goal out from any hierarchy and place the Hand bone as a child of the Forearm bone once again.

 
Step 5: Now select the Soft IK tag that is attached to the Forearm. Tip Effector. In the Constraint tab of the Attributes Manager increase the strength for the goal to 100%.

 
You now need to increase the Anchor Strength for the IK chain. Do this by selecting the Soft IK tag for the Arm Null bone and increase the Anchor Strength to 100% in the Attributes Manager.

 
Step 6: Next, select the Forearm bone and add a Root Goal by going to (Plugins=>MOCCA=>Add Root Goal). Move the Forearm.Root Goal out of the hierarchy and zero out all rotation fields.

 
Move the root goal object away from the elbow area as shown. This will ensure that the elbow area will always point in a specified direction.

 
Step 7: Select the Soft IK tag that is applied to the Forearm bone. Lower the Goal Strength to 30%.

 
Step 8: Okay, the IK chain for the arm is setup. Now you need to create an expression using Xpresso to switch between IK and FK. You will be doing this by using user data fields and turning off the Soft IK tags. Create a Null Object (Objects=>Null Object) and rename it to 'FK / IK Switch'.

 
Create a User Data field for the FK / IK Switch by going to User Data=>Add User Data... in the Attributes Manager. In the Add User Data dialog change the name to 'IK On' and the Data Type to Boolean. This will create a checkbox entry for the null object which will serve as your switch.

 
Step 9: Add a Xpresso tag to the FK / IK Switch by going to File=>New Expression=>Xpresso Expression from the Object Manager. The Xpresso Editor should automatically open.

 
Drag and drop the FK / IK Switch object into the Xpresso Editor to create a node for all of its properties. Now drag and drop all Soft IK tags into the Xpresso Editor as well.

 
Create an output for the FK / IK Switch node by clicking on the top red box and go to User Data=>IK On. Now create inputs for each Soft IK tag Tag Properties=>Use Soft IK.

 
Connect the IK On output to all of the Use Soft IK inputs by dragging wires to each input. Now the user data field that was created earlier turns the Soft IK on and off.

 
Step 10: The switch is basically setup, but currently the Forearm. Tip Goal will not move with the bones once the IK is turned off. So to fix this you will setup a simple expression to move the goal with the Hand bone once the IK is turned off. Drag and drop the Hand bone and Forearm.Tip Goal into the Xpresso Editor. Make two nodes for the Forearm.Tip Goal.

 
Now from within the Xpresso Editor switch over to the X-Pool tab. Create a Condition node by going to System Operators=>Xpresso=>Logic=>Condition.

 
Make sure the node is selected and change the Data Type to Vector. This will allow you to switch between different vector values.

 
Step 11: Now create Global Position outputs for the Hand node along with one of the Forearm.Tip Goal nodes Coordinates=>Global Position=>Global Position. Also create a Global Position input for the other Forearm.Tip Goal node Coordinates=>Global Position=>Global Position.

 
Step 12: You will be basing this switch off of the state of the IK On parameter, so connect the IK On output to the Switch input of the Condition node.

 
Connect the Global Position output of the Hand node to the first input of the Condition node. Pass the Global Position output of the Forearm.Tip Goal to the second Input of the Condition node. Finally pass the Output of the Condition node to the Global Position input of the second Forearm.Tip Goal.

 
Now, when ever the IK is turned off for the chain the Forearm.Tip Goal will move with the Hand bone. This allows you to manually rotate the bones and when you turn IK back on the goal will be in the correct place at the end of the Forearm bone. This prevents the bone chain from snapping back to the influence of the goal once IK is turned back on.

 
NOTE: When animating with this switch, you will want to have the IK On checkbox enabled when animating with IK. Have this checkbox disabled when you are animating with FK. Download the project file for this tutorial to see an example of how to animate with this switch.

 
NOTE: This is not the most mathimatically correct way to setup the swtich of the goal. The more accurate way would be to get the local matrix of the Forearm bone, add the length of the bone to the z position, and subtract the bones vector from that position. But, this math was a little beyond the scope of this tutorial.


© 2004 All rights reserved. For the personal and/or professional use of Cinema 4D users only. Reprint without permission is strictly prohibited.

© 2010 All rights reserved
Copyright Information |
Privacy Policy | Terms of Use