Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Parenting a box to two nulls at once.

  • Parenting a box to two nulls at once.

    Posted by Mikkel Laurendz on December 4, 2017 at 12:15 pm

    What i am trying to achive is a wagon with square wheels.

    I have got the wheels moving and so on, but i need the “body” of the carrige to move with the wheels.

    So the wheels are offset so that they roate opposite of eachother so the body of the wagon needs to rotate a little allso.

    So, i need the two lower corners of a box to be “attatched” to the square wheels.

    Kinda like the line is doing here.

    Any help is appreciated!

    Fud Hodgkinson replied 6 years, 7 months ago 3 Members · 2 Replies
  • 2 Replies
  • Walter Soyka

    December 4, 2017 at 5:55 pm

    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]

  • Fud Hodgkinson

    September 25, 2019 at 12:45 pm

    Hi Walter.
    This was a reeeeeeeeeally handy expression, thanks so much for posting!

    I’m experimenting with different character rigging techniques at the moment and wondered if you could shed any light on your technique above but relating to 3d objects.

    That is to stay, the expression for position works in 3d space but I can’t seem to get the rotation value to work. Would have any idea where I would start to solve this?

    I’ve seen a few radiansToDegrees expressions online but they don’t relate to referencing TWO separate points.

    Example of the problem here: https://youtu.be/jRHFRCFB2v8

    Thanks so much in advance!

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy