Car Rig

Learn how to create a simple but effective car rig

12-00

1. Setup

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.

12-01

2. Drive!

  • 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[0];

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:

[value[0],value[1]-d/2]

We only want to affect the Y position (second value in the array) by half of the diameter (-d/2)

3. Orientation

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[1]-to[1], from[0]-to[0] ) )
  • 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.

12-02

4. Wheels rotation

  • Use the pick whip to link the rotation of the rear wheel with the front wheel

Geometry: circumference ?

12-03

  • Add an expression to the rotation to store the variables
var d = content(“Ellipse 1”).content(“Ellipse Path 1”).size[0];
var p = thisComp.layer(“Drive”).transform.position;
  • Write the expression result : 360º / Circumference * Position

360 / (Math.PI*d) * p[0]

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.

12-04

DON’T FORGET
build your own presets collection to speed up your workflow
Click icon below to download the AE project (rename .key to .zip after download)

download

Advertisements

5 thoughts on “Car Rig

  1. It’s a lot easier to auto-orient the car body to the road, rather than creating a null for the front wheel and programming a time-offset into the rotation. Then you can slow the car down as stop it anywhere on the slope.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s