(Page 1 of 4 pages for this article 1 2 3 > Last »)
Sunday, June 06, 2010
Deeper Modes of Expression, Part 6: Managing Time, Layer Numbers, Speed, and Velocity
Chris Meyer | 06/06
Ways of manipulating time with expressions, including having one layer echo the movements of another with delay.
By default, expressions assume you are interested in values at the current time. If you need to know the current time, just use the keyword time in an expression, and After Effects will return the current time in seconds (not frames, as we discussed in the previous section).
However, expressions allow you to access values at different points in time. They also let you find out what time keyframes and markers are located at so you can have animations change as they approach or cross one of these keys, as well as reference what other layers are doing. In this installment, we’ll explore a couple of ways to exploit time.
Time Echoes
A common animation trick is to have a series of layers performing the same animation, but offset from each other in time. This is easy to accomplish by adding the valueAtTime(t) expression method to the end of an expression that grabs another layer’s values. This method resides in the Property submenu of the expression language menu.
The example below contains a pair of wheels rotating. The wheel on the right (red) is slightly behind the wheel on the left (blue).
  
An alternate way to visualize this is to look at the resulting values curves in the Graph Editor. The identical but offset curves show how one value is following the other, slightly delayed in time:

To make this happen, the red wheel has the following expression applied to its Rotation:
thisComp.layer(“wheel 1”).rotation.valueAtTime(time - 0.1)
This says take wheel 1’s Rotation, but take its value at a time equal to the current time, minus 0.1 seconds. In other words, follow wheel 1’s animation, but delayed by 0.1 seconds.
It was very easy to create this expression: We just dragged the pick whip from wheel 2’s Rotation to wheel 1’s Rotation (which normally makes them exactly the same), then added .valueAtTime(time - 0.1) to the end.
If we wanted, we could replace the 0.1 with an Expression Control, allowing us to edit the time offset without having to edit the expression’s text. After you’ve set this up, remember that you can hold the Command (Control) key while you’re scrubbing the Slider Control’s value to go in smaller increments. We could also set a positive value for wheel 2’s animation to be ahead of, rather than behind, wheel 1.
The valueAtTime trick works for any property. For example, say you had a few words of text that needed to fade on and off, staggered from each other. Once you decide the timing for one word, you want the others to have the same timing, just delayed. You could copy and paste keyframes and slide either the keyframes or text layers later in the Timeline, or use an expression to automate the process (handy if you’re going to be changing the master’s timing later). We’ve done this in the example below:
  
To make this happen, the second word has the following expression attached to its Opacity property:
thisComp.layer(“word 1”).opacity.valueAtTime(time - 0.5)
This adds a half-second delay to the way word 2’s Opacity follows word 1’s Opacity. To make the remaining words stagger behind the previous word by the same amount, we had to edit the expression for word 3 to be delayed by 1.0 seconds, and for word 4 to be delayed by 1.5 seconds. The resulting keyframes and expressions look like this:

To have a series of layers follow the same animation as a master layer, but staggered in time (A–C), you can add .valueAtTime(t) to the end of their expression value, then decide how much to stagger time by – for example, (time – 0.5) says to trail 0.5 seconds behind the current time.
next page: creating expressions based on the layer number
(Page 1 of 4 pages for this article 1 2 3 > Last »)
You must be registered to comment. This is an effort to reduce spam. Please REGISTER HERE.
|