Learn how to create a simple but effective car rig
this simple car rig will automate the rotation of the wheels and the orientation of the car along the motion path. You can use your own car model imported from Photoshop or Illustrator, or create it directly in AE with shape layers. Make sure that each wheels are on a separate layer, and that anchor point is centered.
The simplest hierarchy would be 3 layers:
- Car body
- Front wheel
- Rear wheel
Start by creating the road to be used as a motion path; again, the easiest way would be to create it directly in after effects using shape layers, but you can also import an external file. Doing so will require an extra step, you need to create a mask to outline the curves of the road.
- Create a new Null Object(“Drive”)
- Copy the position property of the front wheel to the Null Object(“Drive”)
- Use the pick whip to link all the car layers to the Null Object(“Drive”)
- Copy the road path from your shape layer or the mask outline to the position property of the Null Object(“Drive”). Make sure you copy the Path and not the object/mask to the position property.
Because the motion path moves the object along its anchor point, we need to offset the Y position of half the diameter of the wheel.
- Add an expression to the Null Object(“Drive”)
If you used a Shape layer, it is easy, you need to get the diameter from the ellipse shape property:
var d = thisComp.layer(“wheel_F”).content(“Ellipse 1”).content(“Ellipse Path 1”).size;
If you imported the layer and don’t know the exact diameter, the easiest will be to create an Effect > Expression Controls > Slider Control, and adjust manually.
var d = effect(“Slider Control”)(“Slider”);
End the expression code with:
We only want to affect the Y position (second value in the array) by half of the diameter (-d/2)
If you toggle on Transform > Auto-orient > Along the path, you can see that the result are more than unexpected. It orients the front wheel, without taking into consideration the rest of the car.
We will solve this problem with an expression on the Null Object(“Drive”) comparing values over time.
- Remove Auto-Orient if you toggled it on
- Add an Effect > Expression Controls > Slider Control to Null Object(“Drive”) and rename it to offset.
- Add an expression to Null Object(“Drive”).rotation; first store the new controller value and convert decimals to Frames for more flexibility*:
var offset = framesToTime(effect(“offset (in frames)”)(“Slider”));
*time is evaluated in seconds in expressions, not in frames
- Create 2 variables to store the positions at current time and past time
var from = transform.position;
var to = transform.position.valueAtTime(time-offset);
- The last part of the expression evaluates the distance between the 2 wheels; if you don’t understand it, please review the previous topic Line Connectors
radiansToDegrees( Math.atan2( from-to, from-to ) )
- Adjust manually the slider(“offset”) so that the rear wheel touches the ground (in positive values)*
*This value depends on the speed (time between the start/end keyframes of the position animation) and the distance travelled in pixels. It should be possible to accumulate values over time to evaluate it, but honestly, it is easier and faster this way.
This setup is not perfect, you will notice sometimes the rear wheel does not stick exactly to the road when the road distortion is heavier. It has to do with the distance between the 2 wheels being forced to always stay the same, despite the distance travelled. But the viewer should not even notice it so why bother? You can still adjust manually if it is really noticeable.
4. Wheels rotation
- Use the pick whip to link the rotation of the rear wheel with the front wheel
Geometry: circumference ?
- Add an expression to the rotation to store the variables
var d = content(“Ellipse 1”).content(“Ellipse Path 1”).size;
var p = thisComp.layer(“Drive”).transform.position;
- Write the expression result : 360º / Circumference * Position
This expression evaluates the rotation speed (360/C) and uses X Position to know how many pixels the car travelled. You can check out CreativeCow Vehicle rig for a more in depth explanation.
build your own presets collection to speed up your workflow
Click icon below to download the AE project (rename .key to .zip after download)