Hey guys, today I will show you how to animate a Cart's Wheels using Expressions in Maya. This is a follow up tutorial of my previous tutorial "Wheel Rotation In 3ds Max Using Parameter Wiring". This time I am showing how to achieve the same result in Maya and I hope Maya users will find it helpful.
In this Maya tutorial, we’ll learn to animate a Trolley/Cart's Wheels using Expressions. The best part is that we don’t need to animate the wheels. We’ll animate the Trolley only, and the Wheels will animate and move automatically. I have created a basic model of the Trolley already. So open the "Start Trolley.mb" file first which is supplied with the tutorial.
Before starting, let’s go through the Trolley parts. So first open the Outliner window to navigate the object list. To open the Outliner window, click on the Window menu and then select Outliner.
You can see there are three major parts of the Trolley listed in the in the Outliner - Handle, Body and Axle.
Select the Handle group and you will see these are separate from the other parts.
Select the Body group and you will see all wooden planks and nails are attached together, but not connected with the other parts.
Select the Axle group and you will see both of the wheels and the axle in this group. So before starting to rig the Trolley, we have to make some special and essential arrangements first.
So let’s start with the Handle group first. Select the Handle group and then press the “Insert” key on the keyboard and you will see its Pivot point.
Now, with the Body part selected, press the “Insert” key and you will see its Pivot point in the middle. It could be anywhere. However we don’t really need to change it because the Body has to be linked as a Child with the Handle.
The Axle group is showing the Pivot point at the center of the Wheels, which it is quite right for rigging it properly.
Now, we will do some parental linking. So first select the Body, then press and hold the Shift key and then select the Handle part and finally press P.
This makes the Body a child of the Handle. Now wherever the Handle goes, the Body will follow.
Now we will create the Expression for the Rotation of the wheels. So select the Axle part and in the Channel Editor, select the Rotation X transform attribute because the wheels would rotate in the X-axis in this case.
With the Axle and its Rotation X transform attribute selected, click on the Edit menu of the Channel Box and select the Expressions... command in the drop down menu.
The Expression Editor window opens. You will see the Axle is selected in the Objects group, while Rotation X is selected in the Attributes group.
In the Expression Text box, write this expression (Axel.rotateX = Handle.translateZ*20;) and then click on the Create button. This Expression says that when the Handle moves in the Z axis, the Axle will rotate the 20th part of the translation. Instead of the value 20, you can check with other values like 30, 40 etc. Actually this value will control the speed of the rotation, so I suggest playing with this value until you get the desired speed of the rotation.
Now, we will connect the Axle to the Handle part, but before that we’ll create a Locator first. So click on the Create menu and then select Locator. The Locator is created on the grid.
Place the Locator near about the Axle as shown in the image below.
First select the Axle part, then select the Locator and press the P key. Now the complete Axle part (with wheels) becomes the child of the Locator.
Finally select the Locator, and then select the Handle part and again press the P key. Now this makes the Locator the child of the Handle. This way, the Handle becomes the parent of all the parts.
Now, select the Handle and drag it in the Z axis. You will see the Wheels also rotate and follow the Handle. You can now make the animation as you want. And the best part is that you only have to animate the Handle and rest of the things will follow it automatically with the rotation of the wheels too.