Animating Wheels With XPresso (And Making An Easy Steering Rig)
One of the biggest hassles in animating cars is that you have to generally keep track of what all the wheels are doing and animate them accordingly. Animating a traffic scene becomes a nightmare.
On my cars, I set up a simple XPresso rig to take care of making the wheels turn. I also make an easy steering rig. Here's how:
First make sure your views are set to Isoparms. This will make it easier to see the wheels spin. Make a quick and dirty car by making a stretched box with four cylinders for wheels. Here's my parameters:
Body (cube): X-100, Y-80, Z-400
Wheels (cylinders): Radius-50, Height- 50, Orientation- +X
Position the wheels, and name them accordingly. Back Left, Back Right, Front Left, Front Right.
Select the back wheels and group them. Name the new group "Back Wheels", and make it the child of the "Body" object.
Create two new nulls and place each one at the center point of each front wheel. For example, my Front Left wheel is located at X- 80, Y- 0, Z- -135. So I placed a null at those coordinates. Go ahead and move the other null at the center coordinates of the other front wheel. Name each null for the wheel that it is located at the center of: Front Left Null and Front Right Null.
Select both of these nulls and make copies of them. Group the copy nulls (Front Right Null.1 and Front Left Null.1) and name the new group "Steering". Drag the "Steering" group out in front of the car and then make it the child of the "Body".

Now, make each wheel the child of the original null (Front Left Null and Front Right Null) that is at the wheel's coordinates. Make all of this the children of the Body.

Create a new null and position it over the body. Name this null "Spinner". In the Attributes, click on the "Object" tab and for "Display" select "Circle". For "Radius", make it 40. Spinner will now be a nice round null that will be easy to see. Make it the child of the "Body".



Now for the fun part. Select "Spinner" and in "Attributes", click on the "Coordinates" tab. Right-Click (Command-Click on Mac) on the "P" in the "R. P" on the right. Select "Animation" and then select "Set Driver".

Select the Front Right wheel object (NOT the null!) and in "Attributes", click on the "Coordinates" tab. Right-Click (Command-Click on Mac) on the "P" in the "R. P" on the right. Select "Animation" and then select "Set Driven (Absolute)".


You'll see an XPresso tag appear next to the Front Right object. If you were to select the Spinner object now and rotate it on its P axis, you would see the Front Right wheel turn with it.


The problem is that to have the wheels turn enough times to convincingly animate the speed of the car over time, we would have to make the Spinner turn hundreds of thousands of degrees, which would get annoying really fast. So, we have to make each degree the Spinner turns produce a proportionally higher turn in the wheels.
Double click on the XPresso tag next to the Front Right wheel. The XPresso Editor will open. Click on the Range Mapper box in the center. Under "Attributes", you'll see the set up for the Range Mapper Operator. We can leave everything here the same except for the Input Upper Parameter. Change that from 360 degrees to 100 degrees.


By doing this, the Front Right object will spin 3.6 degrees (360 divided by 100) per every degree the Spinner rotates.
If you rotate the Spinner now, you'll notice that the wheel spins faster. By lowering the number in the Input Upper, you can make the wheel turn faster in relation to the Spinner. I don't recommend you put in a number lower than 60, though (6 : 1 spin ratio). This is because the wheel will spin so fast that it will be hard to keep track of the rotations and your car could easily have its wheels moving faster than the car is travelling in your animation.
Control-drag the XPresso tag on to the Front Left object and the Back Wheels null (NOT the individual back wheels). Since the back wheels will both always face the same direction, we only have to have their parent null spin and they'll spin accordingly. Now if you rotate the Spinner on its P axis, all the wheels will spin. So to animate the car's wheels, all you have to do is simply keyframe the spinner's rotation and you're all set!


But wait. If you closely, you'll notice that the back wheels rotate the same direction as the Spinner, but the front wheels are going backwards. What happened? It's because the cylinders for that make up the front wheels are on different axes than the Spinner and Back Wheels null. Click on the top view and click on each object. You can see that they're reversed. This is because of the way the cylinders are created. But it's no problem to fix them. Simply select the Front Left and Front Right objects and in "Attributes" change their H rotation to 180. This will rotate them in the right way and all the wheels will spin the same direction.

This is fine for something like these cylinders where they look the same on both sides. You can't tell the difference if they're rotated 180 degrees. But what if this happens with a realistic wheel? The inside of the wheel will look different than the outside. No problem. Just go back into the XPresso Editor, select the Range Mapper, and next to "Input Upper", enter "-100" instead of "100". By having a negative value, the rotation will flip itself, thus making it correct with the Spinner. Like I said, no problem. =)

Now for the steering. This is very easy. Select the Front Right Null and create a Target Expression for it.

Click in the Target Expression next to the Front Right Null object and go to "Attributes" Under "Tag Properties", you'll see a field next to "Target Object". From the Objects Listing, drag the Front Right Null.1 (the child of the "Steering" null) down into the "Target Object" filed.

Repeat this process for the other side: Front Left Null--> Target Expression--> Drag Front Left Null.1 into "Target Object".

Now, select the "Steering" null and move it back and forth horizontally on the X axis. You'll see the front wheels steer accordingly. Ta-Da! Now you're all set to make realistic car animation quickly and easily. Have fun!

PS: To make traffic animate easily, simply create another null, and name it something like "Control". Make its P axis into "Set Driver". Then, select a Spinner on one of the cars. Make its P axis into "Set Driven (Absolute)". Control-drag the Spinner's XPresso tag onto the other cars' Spinners and there you go! Rotate the "Control" on its P-axis, and all of your traffic's wheels will also spin. What a time saver!
You can download the completed project here.