Let’s create one null that can drive the carriage, based on the two points you have: the bouncing centers of each wheel. I’m going to assume you have one layer “Wheel 1” and a second layer “Wheel 2”, and that the anchor point of each layer represents its center.
Here’s an expression for the position of the midpoint of the line segment from Wheel 1’s anchor point to Wheel 2’s anchor point:
p1 = thisComp.layer("Wheel 1").toWorld(thisComp.layer("Wheel 1").transform.anchorPoint);
p2 = thisComp.layer("Wheel 2").toWorld(thisComp.layer("Wheel 2").transform.anchorPoint);
(p1 + p2) / 2;
And here’s an expression for rotation of that midpoint to match the angle:
p1 = thisComp.layer("Wheel 1").toWorld(thisComp.layer("Wheel 1").transform.anchorPoint);
p2 = thisComp.layer("Wheel 2").toWorld(thisComp.layer("Wheel 2").transform.anchorPoint);
delta = p2 - p1;
angle = radiansToDegrees(Math.atan2(delta[1], delta[0])) % 360;
Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn]