This tutorial has been updated.
After so many years I will soon loose all data hotlinked to my Rutgers University account, meaning this tutorial will soon be gutted.
The new tutorial is at:
http://home.comcast.net/~michaelthomasgreer/blender/ActionConstraintsMadeEasy/
Please give me feedback!
The original tutorial starts here:
Action Constraints are a powerful animation feature in Blender. However, I’ve not come across anything that directly addresses the issue of making and using action constraints. Nozzy’s famous rig makes use of them, but it is a fairly advanced setup for the newbie. This tutorial aims to strip out everything but the topic at hand…
Objective
We will tackle animating a spine. Those of you who have tried to do this with IK notice it is very difficult to control that way, and introduces “jumpy” behavior whenever the spine is nearly straight.
Instead, we’ll construct our spine without IK solvers and manipulate it with action constraints. This will give exacting control on exactly how the spine bends.
Assemble your mesh, armature, and views
Here is one of those handsome fellas from MakeHuman 1.8, with an elementary rig. I purposefully left the arms off in order to unclutter this tutorial.
I’ve highlighted here the bones we’re interested in. The Sway Spine bone is the one we will use to control the curvature of the spine when we’re done. For now, however, we’ll ignore it.
Once you’re done setting up your armature, assigning weights, etc., switch over to Pose Mode (Ctrl-Tab).
Action Editor
Open up the Action Editor and add a new action block:
One thing to note is that whenever you add a new action it automatically makes a duplicate of the current action. For this, and one other reason we will make note of shortly, let’s add another new action.
The action name should now read “Action.001”
Change it to “Sway Spine”
It is not required to have a name matching any bone (or anything else in Blender) --you could have named it “fooey kablooey”. My preference is simply to name the actions --and the bones that control them-- as descriptively as possible. For me that means that they’ll have the same name.
Adding the first key
Adding an action is just like normal key animation. Since our ‘swaying’ action is to sway between the left and the right, our central, ‘neutral’ pose should be somewhere in the middle.
Pressed the Up-Arrow key to move to frame 11. There’s nothing special about frame 11, it’s just where I’m putting my center key. Select the bones of the spine and press ‘I’ --> Insert Loc/Rot.
The Action Editor will display the new keys:
Additional Keys
Let’s bend the spine right, shall we?
Set the frame to 1 and play with the spine until it’s somewhere you like it.
You’ll notice that I’ve kept his head up. All this action is designed to do is curve the spine. Not bend over at the hips. We can use the Spine A bone for that later.
Press ‘I’ and insert another Loc/Rot.
Next I changed to frame 21 (the last frame in the action), adjusted the spine bones appropriately, and inserted the final key.
You can, of course, use all the normal action editing techniques here to test your frames. Go to frame 1, press Alt-A, and watch him sway from his right to his left. Add, delete, and rearrange keys until you are satisfied with the motion.
The center key
Since this action is centered at frame 11, set the frame number to 11. Now select the “Action” action from the combobox. You can now change the frame number back to 1.
The location of the frame index is important for an action. In most cases, you can leave it at 1. But for an action like this we want it in the middle of the action.
This is the other reason for having an empty Action block from which to build new actions. It just makes life a little easier to not have to worry about those things.
Applying the Action Constraint
Now to make our boy dance.
Select the bone labeled “Spine A” and press F7 to display the Object Buttons. Under the Constraints tab, add an action constraint.
Target
For “Target” type in the name of your armature.
A new box will display. Type in the name of the bone which will control the spine: “Sway Spine”.
Action
In the box that says “AC:” type in the name of the action “Sway Spine”.
Don’t be concerned that the armature deforms in the 3D View. We’ll fix that.
Rotation Axis
The degree we rotate our bone around the Z-axis is what controls the action. You can make it any axis you want, or change it later if needed or desired.
Start and End
Our action begins at frame 1 and ends at frame 21.
Min and Max
I like the greatest range of motion possible, so it’s 90.00 to -90.00 degrees.
At this point you can grab the Sway Spine bone and rotate it to see what happens. I had initially set my min and max to -90 to 90, which made him sway left when I rotated the bone right. So I swapped them to make it do what I want.
The only thing remaining is to repeat the process of applying the action constraint to Spine B and Spine C. Notice how we never did anything to the Sway Spine bone?
In Blender, constraints are applied to the controlled bone, and target the controller bone.
The Null Constraint
One important thing that should be mentioned here concerns the use of a Null Constraint. In our example each bone of the spine (A, B, and C) has only one Action Constraint applied to it.
However, it is often convenient to apply multiple action constraints to the same bone. The next logical step for our spine would be to create another action called “Bend Spine” which makes the spine curve forward and backward (slouch and stretch, as it were). We would then need two bones to manipulate the spine: “BO:Sway Spine” and “BO:Bend Spine”, and two corresponding actions that do each one: “AC:Sway Spine” and “AC:Bend Spine”.
Each bone in the spine would then have two Action Constraints applied to it: one targeting the “Bend Spine” bone and action, and one targeting the “Sway Spine” bone and action.
In Blender, if two or more constraints of the same type are applied in sequence, the result is an average of the constraints. This is useful for doing something like constraining an object to track the point between two or more other objects. In the case of Action Constraints, however, the average result is usually undesireable.
To solve the problem, place a Null Constraint between each Action Constraint to prevent them from being averaged together. The result should look something like this:
To move a constraint up or down in the list, collapse it (click the little triangle), and click the name to get a pop-up dialogue to move it up or down.
Using the Action
The only thing left to do is play with the new action constraints.
Since we’ll never need to mess with Spine B and Spine C, Tab into edit mode and hide them. Now Ctrl-Tab back to Pose mode. The action editor should read “AC:Action”. Good.
Animate as usual. You can rotate the Sway Spine bone left and right to control the entire spine, and rotate the Spine A bone to make him bend at the hips.
Here’s my animation doing just that. (DivX 328KB)
I hope this helps. If I’ve left anything out, or have been unclear, let me know.
Added information about Null Constraints (18 Sep 2005)