# Creative Communities of the World Forums

The peer to peer support community for media production professionals.

• # balance

3 Members · 4 Posts
• ### Aqeel Sami

October 31, 2009 at 4:28 pm

i need to make a balance with a horizontal bar which have two trays hanging on both sides. i want to put weights on one of the trays and i want to rotate the horizontal bar while still holding the tray and i want to do that in a realistic way… how could i connect the tray y position with the rotation of the horizontal bar to keep them touching each other. any suggestion or help ?

• ### Erik Waluska

November 1, 2009 at 5:09 pm

You would need to change the anchor points of the tray layers to the point at which they connect to the bar and then parent them to the bar. To keep them level when the bar rotates you will need to pick whip the rotation property of the trays to the rotation property of the bar and add -1 to the end of the expression.

Check out this example project:
357_scales.aep.zip

Hope that helps.

-E

• ### Roland R. Kahlenberg

November 1, 2009 at 5:34 pm

You’ll need to create two relationships –
1) between the two trays
When one tray moves down by a value, the other tray has to move up by the same amount.

2) between the trays and the horizontal bar
When either one of the tray moves, the horizontal bar’s rotation values kicks in. We will use the right tray to drive the horizontal bar’s rotation values as well as the left tra’s Y-position.

It’s best to create a Null to use as a Controller Layer that holds the Expression Sliders that we’ll be using.

Create the Null and apply the Expression Slider five times and change each of their names to –
MaxRotation
MinRotation
MaxYPosition
MinYPosition
StartRightYPos

Type the following values in the Slider value inpit parameterfor the above Expression Controllers-

MaxRotation = 70
MinRotation = -70
MaxYPosition = 530
MinYPosition = 0
StartRightYPos = 400

While most of the values can be adjusted, the StartRightYPos parameter has to be exactly the starting values for the trays. I am assuming that the trays start off at equal heights.

Now put the following script into the horizontal bar’s Rotation Expression –

//Start Script
MaxRotation = thisComp.layer(“Null 1”).effect(“MaxRotation”)(“Slider”);
MinRotation = thisComp.layer(“Null 1”).effect(“MinRotation”)(“Slider”);
MaxYPos = thisComp.layer(“Null 1”).effect(“MaxYPos(right)”)(“Slider”);
MinYPos = thisComp.layer(“Null 1”).effect(“MinYPos(right)”)(“Slider”);
LayerProp = thisComp.layer(“right”).position[1];
LeftYPos = thisComp.layer(“left”).position[1];
RightYPos = thisComp.layer(“right”).position[1];
if (LeftYPos==RightYPos)
0
else
linear(LayerProp,MinYPos,MaxYPos,MinRotation,MaxRotation)

// End of SCript

And for the left tray, put the following script into its Position property’s Expression box –
// Start Script
RightYPos = thisComp.layer(“right”).position[1];
StartYPosRight = thisComp.layer(“Null 1”).effect(“Start RigthYPos”)(“Slider”);
[value[0],((value[1]-RightYPos)+StartYPosRight)]
// End SCript

Once you have these setup, you simply have to animate the Y-positionof the right tray to get the Horizontal bar to rotate. How much it rotates depends on the values for MinRotation and MaxRotation and even MinYPosition and MaxYPosition value adjustments will affect the sensitivity of the amount of rotation depending on the y movement of the right tray.

HTH
RoRK

• ### Erik Waluska

November 2, 2009 at 1:17 am

Actually, that’s supposed to say “add *-1 to the end of the expression”. It’s correct in the project file, I just forgot it in the post. Sorry about that.

-E

Viewing 1 - 4 of 4 posts