beautypg.com

Expression example: rotate the hands of a clock – Adobe After Effects User Manual

Page 706

background image

To the top

To the top

You can create an expression without using properties from other layers. For example, you can make a layer revolve in a perfect circle.

1. Select a layer, press P to reveal its Position property in the Timeline panel, and Alt-click (Windows) or Option-click (Mac OS) the stopwatch

to the left of the property name.

2. Enter the following in the expression field:

[(thisComp.width/2), (thisComp.height/2)] + [Math.sin(time)*50, -Math.cos(time)*50]

Expression example: Rotate the hands of a clock

You can use the pick whip to link rotation values between layers to animate the hands on a clock—as the hour hand moves from hour to hour, the
minute hand rotates the full circumference of the clock face. This type of animation would take a long time to create if you had to set each
keyframe for both hand layers, but with the pick whip, you can do it in a matter of minutes.

1. Import or create two long, narrow solid-color layers: an hour hand and a minute hand. (See Solid-color layers and solid-color footage items.)

2. Set the anchor points at the ends of the layers. (See Layer anchor points.)

3. Move the layers so that the anchor points are at the center of the composition. (See Move layers in space.)

4. Set Rotation keyframes for the hour hand. (See Set or add keyframes.)

5. Select the Rotation property for the minute hand and choose Animation > Add Expression.

6. Drag the pick whip to the Rotation property for the hour hand. The following expression appears:

thisComp.layer("hour hand").rotation

7. To make the minute hand rotate 12 times as fast as the hour hand, add *12 at the end of the expression as follows:

thisComp.layer("hour hand").rotation*12

Guy Chen provides a simple project on the

After Effects Exchange

on the Adobe website that takes this idea further, connecting the rotation of the

minute hand and hour hand of a clock to the rotation of the second hand.

Expression example: Position one layer between two others

This example expression positions and maintains one layer at a balanced distance between two other layers.

1. Start with three layers. (See Creating layers.)

2. Animate the positions of the first two layers in the Timeline panel. (See Motion paths.)

3. Select the third layer, press P to reveal the Position property, and Alt-click (Windows) or Option-click (Mac OS) the stopwatch button to

the left of the property name.

4. Enter the following in the expression field:

(thisComp.layer(1).position + thisComp.layer(2).position)/2

702

This manual is related to the following products: