If you connect two different properties using an expression, you may find that even after you change the direction of the change by multiplying by minus 1, the expression still does not do what you need it to do. In this movie, author Luisa Winters walks you through how to change the rate of an expression.
- If you connect two different properties using an expression, you may find that even after you adjust the direction of the change by multiplying by minus one, the expression still does not do what you need it to do. Maybe the rate of change is too slow, maybe it is too fast. Let's go through what to do when that happens. Let's go ahead and open Composition 2.1, "Changing the Rate of an Expression." In here, you're gonna see two familiar layers, you're gonna see the dimmer on the left and the light bulb on the right, and what we're going to do is we're gonna keyframes to the dimmer so that it rotates 180 degrees left.
Let's go ahead and do that. So we keyframe rotation, now I'm gonna go all the way to the end of the composition, and I'm gonna add another keyframe there, and maybe change the value to minus 180. And now if I play it back, indeed it takes 30 seconds to go from rotation zero to rotation minus 180. Now, let's go ahead and add an expression to the opacity of the lightbulb. Press and hold alt or option and now pick whip from the opacity of the light bulb to the rotation of the dimmer.
And indeed, this is what the expression writes. This comp layer dimmer transformed rotation. So it's indeed connecting the opacity of one layer to the rotation of another. Let's go ahead and scrub the timeline. As you can see, it's not working at all. The reason for that is because rotation is going from zero to minus 180, and opacity can only exist between zero and 100.
There are no negative values that exist in opacity. I can't really multiply it by minus one, because if I do that, then the values will go up, they'll go from zero to 180, which is the opposite of what I want to do. Now for the light bulb, I want a value of 100 for the opacity at the beginning of the composition. So my play head is at the very beginning, the value is zero, and I want 100.
All I have to do is add 100 and now, sure enough, the light bulb appears. If I scrub the timeline, you're gonna see that the light bulb becomes completely invisible before the dimmer has a chance to reach the value of minus 180. So the rate of change of these two values is not the same. I need to put 180, which is how many degrees the dimmer needs to change, I need to put that value inside of 100, which is how many percentage points the light bulb needs to dim.
To do that, I can easily do it by multiplying for 100 and dividing 180. I need to do that before I add the value. So I delete the plus 100, and now I can multiply by 100, asterisk 100, divide by 180, that's slash 180. Now let's see what that does. And of course it's not going to do anything, because I can multiply zero by 100 and divide it by anything I want, and the value is still gonna be zero.
But that did fix the rate of change. All I have to do now is adjust the value, so at the very beginning, I have zero, but I want 100, all I have to do is add it. So plus 100 and there it is. Now, the rate of change of both properties will agree 100%. So, when you are connecting two properties, you should look at the expression and adjust what is necessary in the following order.
One, make sure that the direction is okay. If it's not, multiply by minus one. Two, adjust the rate, if you need to. This is always accomplished by multiplication and division. Three, adjust the actual value of the property if you need to. This is always done by adding or subtracting.
- Adding expressions
- Editing expressions manually
- Changing expression dimensions: rate, value, music amplitude, etc.
- Working with expression variables
- Using the Expression Language menu
- Using random values