FORUMS: list search recent posts

# Parenting a box to two nulls at once.

FAQ   •   VIEW ALL
 Parenting a box to two nulls at once. on Dec 4, 2017 at 12:15:01 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!

 Re: Parenting a box to two nulls at once.on Dec 4, 2017 at 5:55:14 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
Motion Graphics, Widescreen Events, Presentation Design, and Consulting

 Re: Parenting a box to two nulls at once.on Sep 25, 2019 at 12:45:35 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: