“Attaching a Walk cycle to a motion path in Maya”
By
Kiel Figgins
www.3dfiggins.com






Introduction
In this example file, I did a leg doing a quick walk cycle. Though theres only one leg, but the same princibles would apply for two or more.

The two key elements for getting a character to move without sliding feet is making sure their foot plants are static and their movement rates match their stepping rate. The steps below will show you how to achieve both of these.

To download the animation example file, click the link below:
Assets


Part 1: Static foot plants
*All values are using the supplied file as a base, in your own files the values will be different.

While the foot is planted (ty = 0) from frame 2 to frame 12, the initial translate z keys have a slight bow in the curve.



What you'll want to do is select the two TZ keys (f2 and f12) and set them to Linear.


So now, as your foot is planted on the ground, it won't simmer or shift. You'll want to do this same process on the other axis' (X and Y) to prevent skewing there as well.


Part 2: Moving Forward in world space

Key Notes for CTRL_Foot:
Frame 2 Translate Z = 2.059
Frame 12 Translate Z = -2.359

With those values in mind, some basic math equations:

Step Range = (12 - 2) = 10 frames
Step Distance = (abs(-2.359) + abs(2.059)) = 4.434 units
*simply put, just add the numbers together, disgarding any negatives, so 2.359 + 2.059

So our leg is moving 4.434 units over 10 frames.

Now getting it to move forward:

-Select Leg_Rig
-Go to frame 0
-Set a key on the translates of Leg_Rig
-Go to frame 10
-Set Translate Z to 4.434
-Set a key on the translates of Leg_Rig

-In the Graph Editor, select Leg_Rig.tz
-View > Infinity
-Curves > Pre Infinity > Linear
-Curves > Post Infinity > Linear


Now the leg will walk forward and the foot will stick to the ground appropriately.


Part 3: Moving on a motion path

However, a common question is how to attach a walk cycle to a motion path? Using the above procedure it's pretty straight forward.

-Go to frame 0
-Delete the existing keys on Leg_Rig, making sure that all the translates and rotates are set back to 0
-Select Leg_Rig, then shift select the motion_Path curve
-Animate > Motion Paths > Attach to Motion Path > Option Box
-Edit > Reset Settings
-Front Axis Z
-Click Attach

Now this is a bit tricky, finding out the length of your curve. There are two ways, and depending on preference or time requirements, both work fine.

1. Eye ball it. Since you know that your foot will plant fine when its moved linearly over time. You could adjust the motionPath1.uValues and get the results you need.
*This is typically my approach. Quick, easy and I like adjusting keys instead of more math.

2. MEL and more Math

Run the below code in Script Editor
*If your working with a custom scene, you'd want to replace Motion_PathShape with whatever name of the curve your using.

createNode -n "walkingCurveInfo" curveInfo ;
connectAttr  Motion_PathShape.worldSpace[0] walkingCurveInfo.inputCurve;
select walkingCurveInfo;

-Open the Attribute Editor
-You'll see a field called Arc Length and a value next to it (72.286 in my example)

Math:
Steps Needed: 72.286 / 4.434 = 16.3
*(Curve Distance / Step Distance)

Frames Per Step Range: 10

Total Frames needed: 16.3*10 = 163
*(Steps Needed * Framers per step)

-With that number (163) set the motionPath U value to frame 163




Conclusion
So theres how you can attach a walk cycle to a motion path. Fairly straight forward with minimual math and effort. After doing it once or twice, it becomes very quick to setup. Once your done though, typically you'll want to delete walkingCurveInfo, if your not using it any more.


Final Note:
The foot may be planted positionally to the correct spot, but since we attached its top node (Leg_Rig) to the motion path, its always going to aiming/rotating down the path, meaning that the foot is going to be pivoting while planted. Depending on where the camera is, the type and size of foot or several other factors, this should be fine. As the camera gets closer you'll want to animate the the character physically moving forward and not use a motion path.

Enjoy and happy animating!