From BlenderWiki

Jump to: navigation, search

Stride

One very common animation need is to make a character or object move. Yes, incredible, isn’t it? Let’s precise this a bit: to make it moves in its environment, e.g. a human walking or running in the street, a bicycle going on a road… Now, at this point, you should know Blender features a very powerful tool for such “global translation” movements: the curves used as paths. They allow you to easily control the position and/or speed of your object along them.

Fine, but if this is enough for things like planes or space ships, which have no visible physical interaction with they environment (they only “touch” gas, which is usually not visible…), when it comes to wheels rolling on asphalt, or even worth, characters walking, it won’t do it. Imagine wheels immobile, or rolling at a constant speed while the bicycle slows down on the hills and speeds up downhill. And for walking characters, not only have they to vary their movements according to the path’s speed, but they also often have to vary their speed inside their walk cycle, to avoid their feet to slide when they should stick to the ground!

You could obviously forget cyclic actions and animate the whole path by hand, but this would take you many time, and wouldn’t even always give you the best results – not to mention that you would have to redo everything if you decide to modify the movement later on… To address this, Blender has a quite powerful tool, known as stride.

The idea behind it is simple. Granted that you have created a cyclic action, stride will “expand” it all along the path. It just asks you how long (in dimension, not in time!) is your action. So if your rolling wheel is 1 BU of radius, it rolls over 2π × 1 = 6.2832 Blender Units each complete revolution, and stride will adjust (pull/shrink) its rotating action so that it makes one revolution every 6.2832 BU along the path… Your wheel will no more slide on the asphalt!

Exclamation mark.png
Before we go any further, there are a few important points to grasp:
  • Even though the stride option is available for all action strips in the NLA, it only works on pose actions (i.e. actions having one or more bones animation channels). In other words, it’s reserved to armatures!
  • Further more, your “stridden” armature must follow a path, else stride is completely useless.
  • Unfortunately, the stride tool only works with the old “follow path” parenting technique (i.e. when parenting an object, here an armature, to a curve with the CtrlP shortcut, and choosing Follow Path from the Make Parent menu that pops-up). You can’t use the Follow Path constraint here! Sad!
  • The “stridden” action strip must be at least as long as needed by the path (in time/frames, this time!). So, you can either repeat it several times (Repeat numeric field in the NLA’s Transform Properties panel), or expand it (Scale numeric field, in the same panel). Remember that stride takes control on how this action is played, so its representation in the NLA is no more relevant anyway… The two only important things remain its start and end frames: if they are “inside” the path’s defined movement, your object won’t stride (it will just slide) until start frame, and/or after end frame.

Basic Stride

Let’s start with the “basic” stride, which assumes that your action is linear along all its length. In other words, if your wheel makes 6.2832 BU each revolution, it assumes that if the path is 3.1415 BU length, it has to make your wheel advance of exactly 3.1415 BU (and play half of the action), and so on. As you might have guessed, this won’t do it with non-linear movements, like walk cycles, for example… We will see how to solve this problem with the “advanced” stride and its stride root bone, later on.

The default NLA Transform Properties panel.
The same panel with stride enabled.

All basic stride controls are found in the Transform Properties panel of the NLA Editor window. To show them, you must first enable the Stride Path button.

This displays two additional rows of controls, but with basic stride you only need the top one:

Disable
When enabled, it will disable the “follow path” stuff, which might be useful e.g. if you want to tweak your “stride” action.
Offs
This numeric field is a frame offset that allows you to tweak the stride action’s start. For example, if you set it to 10, your armature at the start of the strip will be in the same state as ten frames after the start of the action.
Stri
The stride distance, i.e. the distance covered by a whole cycle of the action…

Example

Now, the best way to understand the stride tool is to use an example – here we will use nearly the same as in this tutorial: a wheel rolling along a path. It will also gives us the opportunity to demonstrate how to use the stride tool for objects (as here, the armature will only be a sort of mandatory proxy to use stride on our wheel mesh – otherwise, we do not need bones just to make roll an object!).

I’ll assume you know how to get a torus mesh of one BU of radius, that will be our wheel (⇧ ShiftA  »  Mesh » Torus, with a Major Radius of 0.8, and a Minor Radius of 0.2…). Add also an armature (one bone is enough).

Now, parent your wheel to the bone of your armature (and not to the armature itself!). The easiest way is to add a Child Of constraint to the wheel, with the armature and its bone as target!

Now, when you will move the bone, the wheel will follow. Well, time to create your cyclic rolling action! There’s a tricky point here: creating a smooth constant rotation with quaternions is not trivial! Unlike with standard “angle” curves, you cannot just create linear curves. Moreover, Blender’s management of bones’ angles is somewhat disturbing, as it always clamp them back into the [-180°, 180°[ range… Here is the method I used to create a quite satisfying rotation around the bone’s Z axis:

  • Switch to Pose mode (Ctrl⇆ Tab), and select your bone.
  • Insert at frame 1 a rotation key.
  • Head up five frames, rotate your bone of exactly -18° around its local Z axis (R, Z, Z, -18, ↵ Enter), and insert another rotation key.
  • Repeat the previous step until you reach frame 101 (included).
  • Finally, set the extrapolation to Cyclic (E3 NumPad in the Ipo window). This will “sharpen” the start and end of the QuatZ curve…
The Quaternion Ipo curves of a constant rotation.

Now, you can see in (The Quaternion Ipo curves of a constant rotation) the QuatW and QuatZ Ipo curves this produces… The Bézier interpolation with a few points is not enough to recreate it, you need many points. In fact, these curves seem to me like sinusoids… So I guess Python Ipo drivers could fit here, except that they do not seem to work with stride!

Nevertheless, you have a good (even though not perfect!) rolling bone, and hence a good rolling wheel. As you know, bones’ animation always are actions, so you also have your stride action.

Add a curve (a Path one, for example…) in your scene, give it the shape you want, and edit its Speed curve (Path Ipo curves) to your liking (see this page to learn more about paths and the Speed curve).

Parent your armature (as an object, this time, i.e. back in Object mode) to your path, using the old method: CtrlP  »  Follow Path.

Now, the armature – and the wheel – follow the path, but they just make one revolution, without even adjusting their rotation speed to their translation!

Well, open a NLA window (Ctrl⇧ ShiftF12), and add as a strip your armature’s action. Make sure it covers the whole path’s duration (scale it if necessary, this won’t have any effect at the end). Open its Transform Properties panel, and enable the Stride Path button. You only have to define the length “rolled” by your action – as it’s a one BU radius wheel, you need to type in the Stri field 6.2832.

Et voilà! Your wheel is now following its path, rolling accordingly to its speed. If you make it go back along the path (by giving the Speed Ipo curve a negative gradient somewhere), you’ll even note that stride reverts the action as well, so that the wheel rolls back!

Here is the final video of this example (you can download the blend file File:ManAnimationTechsArmaturesStrideExRollingWheel.blend).



Advanced Stride

Now, this works well with constant, linear actions, but what if you would like to precisely control the speed of your object inside its stride action? For example, a human walking has its forward speed varying during its walk cycle, e.g. to avoid its feet to slide on the ground!

To achieve such control, stride features an advanced option, known as “stride root bone”. Basically, it uses the translation of this bone inside its local space, and along a chosen axis, as reference. In other words, it works like this:

  1. At the beginning of a new action cycle, it takes the current position (along the path) of this stride bone.
  2. During all the cycle, it makes the whole armature goes forth and back along the path, so that the stride bone remains exactly at the same place along the path (and along its reference axis).
  3. Once the action cycle is ended (i.e. the armature has walked as long as the “stride distance” defined in the stride action by the stride bone), the stride bone is instantaneously put forward of this distance, and everything starts over.
Exclamation mark.png
This implies several points:
  • The stride bone is used as if stuck to the ground by the stride tool. But inside the stride action, it must moves inside its armature, which implies that it must move reversed compared to the final wanted movement. For example, to make the armature move forward of one BU during the whole stride action, its stride root bone must in fact move backward of one BU, while the rest of the armature remains (more or less) at the same place.
  • As the bones are keyed in their local space, a good idea is to always use the Y axis of the stride bone as reference. This way, whatever is its visual orientation, you know that it is its translation along its own direction that will be used by the stride tool.
  • The distance between the first and last key position of the stride bone defines the length the action’s cycle will cover along the path. In other words, it becomes the “stride distance” we saw above, and hence, the Stri value of the NLA Transform Properties panel has no more effect.
  • The movement of the stride root bone along its reference axis can go forth and back. However, its extreme values should be at the start and end frames (in other words, inside the action, it should always remain between its start and end positions). Else, you will get strange behaviors (namely, the stride bone, supposed to remain stationary, will move…).
  • In general, the stride bone has no other means, and is completely unlinked from the other rig’s bones.
  • If you want a specific bone to not move along the path (i.e. stick to the floor), you have to make it move in conjunction with the stride bone.
  • Use the Disable option in the NLA Transform Properties panel to quickly switch between keying the stride bone and seeing the result.
The NLA Transform Properties panel with stride enabled.

In addition to the first controls’ row of the NLA Transform Properties panel, you have in the second one:

X, Y, Z
These three buttons (mutually exclusive) allow you to choose along which axis the stride bone’s movement is evaluated.
Stride Bone
You can type in this text field the name of the stride bone.
However, there is another way to specify the stride bone of an armature: in Pose mode, in the Armature Bones panel (Editing context, F9), each bone’s sub-panel has a Stride Root button, which you can enable to get the same effect.
Note that this field is not updated if you modify the name of your stride bone! So in such case, you’ll have to refresh it yourself by hand…

Example

Here again, a small example should help you understand all this. Here we will create a very raw and simplified version of a walk cycle – you can also have a look to this tutorial.

To keep it the most readable possible, we will only create one leg here – feel free to create the other one if you like, as an exercise!

Add an armature, and create a three-bones leg (with connected bones), plus a free bone, which will be our stride root one. Rotate this one so that it points in the forward direction (this way it will be its Y axis’ translation that defines the stride movements).

Then, switch to Pose mode, and create your walk cycle, adding half a dozen of keyframes to get something similar to what’s shown below. Note how the foot bone moves exactly as the stride one, when it is stuck to the ground… You can also define here your stride root bone (in the Armature Bones panel of the Editing context, F9). Note how it becomes of a darker shade of blue…



Then, add a path, and parent your armature to it so that it follows it (CtrlP3 NumPad).

Now, open a NLA Editor window (Ctrl⇧ ShiftF12), add as a strip the pose action you just defined, and show its Transform Properties panel (N). Enable the Stride Path button, and choose the Y axis for your stride bone (its name should be already set in the Stride Bone field…). Check that your animation’s strip is long enough for your path’s duration (else, either repeat it, or scale it).

If you hit AltA, you should get something similar to the video below.



Note:

  • How the “parent relationship” dashed black line materialized the position along the curve that the armature object would get, without its stride bone.
  • That here again, reversed movements along the path (i.e. negative slope in its Speed Ipo curve) are handled correctly. However, in a real situation, this won’t be enough, as a human’s backward walk is not just a reversed forward walk…

You can download the blend file of this demo File:ManAnimationTechsArmaturesStrideBoneExWalkingLeg.blend.