ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud


COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Aqeel Sami
on Oct 31, 2009 at 4:28:05 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 ?

Return to posts index

Erik Waluska
Re: balance
on Nov 1, 2009 at 5:09:27 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:

Hope that helps.


Return to posts index

Erik Waluska
Re: balance
on Nov 2, 2009 at 1:17:54 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.


Return to posts index

Roland R. Kahlenberg
Re: balance
on Nov 1, 2009 at 5:34:55 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 -

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)

// 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");
// 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.


Sell your AEPs with broadcastGEMs' DVD series of templates. Click here for more

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 All Rights Reserved