In this post, I will show you how to create a hover over effect in After Effects.
Step 1: Opacity Reveal Keyboard Shortcut
Select the UKRAMEDIA.COM text in the timeline and press T to reveal the opacity.
Step 2: Activate the Expression
Press ALT-LMB on a PC (OPT+LMB on a Mac) on a stopwatch icon to activate the expression.
Step 3: Set Variables
I’m going to set some variables inside of the text box.
First Variable: pointA
The first variable is going to be pointA and it is going to be the Center shape layer.
pointA = theComp.layer(“center”)
I also want the anchor point of that rectangular shape layer, so I’m going to say
toComp(anchorPoint)
The Anchor Point has two coordinates. It has the X and the Y. I want the Y coordinate, so that’s going to be the index 1.
toComp(anchorPoint)[1];
Next, I am going to set up pointB.
Second Variable: pointB
pointB = thisLayer.toComp(anchorPoint)[1];
Now I’m going to use the length expression to find the value between these two points.
Length Expression
I’m going to say L, you are going to stand for the length expression:
l = length();
Inside the (), I’m going to say find the length between pointA and pointB like so:
l = length(pointA, pointB);
So if I select the Center shape layer and hit P to reveal the position.
Then if I move the Center shape layer down away from the UKRAMEDIA.COM text, you can see that the opacity will change to 100%.
We are almost there but let me show you a few other things we need to set up.
Let’s undo everything with the keyboard shortcut CTL+Z on PC (CMD+Z on a Mac).
Linear Expression
Next, I’m going to do a linear expression. I’m going to say, linear and then in parentheses, I’m going to say the following:
linear(l, 0, 110, 100, 30)
Let’s break it down.
I’m going to use the L value here. I’m going to say that anytime the L value is zero or in other words, anytime both the UKRAMEDIA.COM text and the Center shape layer is on top of each other, I want a certain thing to happen.
Then when the Center shape layer is 110 pixels away on either side (up or down), I want it to do a certain thing as well.
So when the L value is zero, or when it’s exactly on top of each other, I want it to be at one 100% in opacity.
Now when this Center shape layer is further away, let’s say at 110 pixels, I want it to have 30% opacity.
Let’s see if this works.
So right now the Center shape layer is on top and the opacity is almost at 100%.
If I move the Center shape layer down, you can see that it went down to 30% opacity.
The same thing will happen if I move the Center shape layer up in the other direction.
So that’s pretty much it but let me show you another thing we can do.
First, I’m going to undo everything with the keyboard shortcut CTL+Z on a PC (OPT+Z on a Mac)
I’m going to select and copy everything inside of my text box with the copy keyboard shortcut CTRL+C on a PC or CMD+C on a Mac.
Next, I’m going to select my UKRAMEDIA.COM text layer and hit S to reveal the Scale Property.
We will need to activate expressions by clicking on the stopwatch icon.
I’m going to paste the same expression we copied earlier to my scale expression with the keyboard shortcut CTRL+V on a PC or CMD+V on a Mac.
Converting Scale to Two Dimensions
Now, the only problem is that the scale has two dimensions and opacity had only one. So we
have to convert the scale to two dimensions.
To do that, we have to give it some kind of variable.
I am going to say
s = linear(l, 0, 110, 100, 30)
and then in here next line, I’m going to define the S in the square brackets. I am going to say X, you are going to be S and Y is also going to be S as well.
s = linear(l, 0, 110, 100, 30)
[s, s]
Now, if I move the position of my Center shape layer down or up, you can see that it’s doing some cool stuff. It will scale my text layer.
The only problem is that I don’t want to scale down the text layer that much, so I’m going to restrict it to 90 instead.
Now if I move the Center shape layer up or down, you can see that it has a gradual scale.
Let me show you another thing you can do but first, let’s hit U to hide everything.
Let’s duplicate the UKRAMEDIA.COM text layer by selecting it and pressing CTRL+D on a PC or CMD+D on a Mac.
Select the UKRAMEDIA.COM 2 layer and do SHIFT+UP arrow key six times.
Next, I am going to select the original text layer UKRAMEDIA.COM again duplicate it with the keyboard shortcut CTRL+D on a PC/CMD+D on a Mac.
Select UKRAMEDIA.COM 3 text layer and shift arrow down six times.
Now if I select the Center shape layer and when I move it around, you can see that it’s giving us that hover over effect.
I hope you enjoyed this tip. You can download the project file below and check out my Learn After Effects Expressions course if you want to learn more about Expressions and how it can speed up your workflow in After Effects.
Download Project File
[sociallocker]