After Effects Tip: How To Create a Hover-Over Effect

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.

Press T to reveal opacity in After Effects

Step 2: Activate the Expression

Press ALT-LMB on a PC (OPT+LMB on a Mac) on a stopwatch icon to activate the expression.

Activate Expressions in After Effects icon stopwatch

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.

Center Shape layer in After EffectsCenter Shape layer in After Effects

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 After Effects

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.

Select the shape layer in After Effects

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%.

Moving away in After Effects

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).

Undo keyboard shortcut in After Effects

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.

linear expressions in after effects

Let’s see if this works.

So right now the Center shape layer is on top and the opacity is almost at 100%.

on top After Effects

If I move the Center shape layer down, you can see that it went down to 30% opacity.

opacity change in After Effects

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)

Undo After Effects
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.

select and copy in after effects

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.

Activate the expression in After Effects 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.

Paste expression keyboard shortcut after effects

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.

Moving position up and down in After Effects

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.

restrict to 90 scale after effects
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.

hide keyboard shortcut in After Effects

Let’s duplicate the UKRAMEDIA.COM text layer by selecting it and pressing CTRL+D on a PC or CMD+D on a Mac.

duplicate layer keyboard shorcut in After Effects

Select the UKRAMEDIA.COM 2 layer and do SHIFT+UP arrow key six times.

shift up keyboard shortcut in After Effects
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.

duplicate keyboard shortcut in Adobe After Effects

Select UKRAMEDIA.COM 3 text layer and shift arrow down six times.

shift down keyboard shorcut in After Effects

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]
Download Tip 32 Project File
[/sociallocker]

About the author:

Sergei Prokhnevskiy

Sergei Prokhnevskiy is a Charlotte, NC based motion graphics designer, an online tutor, an entrepreneur, and Adobe MAX Master Speaker. Sergei is known for his quick and practical After Effects tips and tricks on YouTube, where he generated well over 6 million views on his tutorials. He has authored an online video course on After Effects Expressions and developed scripts for After Effects. He is also a former senior motion graphics designer at Fox Sports where he worked on graphics for NFL, Super Bowl, MLB, World Series, College Football, NASCAR, Women’s World Cup, and NASCAR Race Hub. He is very passionate about learning and teaching others.

5 FREE TIME-SAVING TOOLS!

Over 100,000 downloads & counting!

These 5 tools will seriously speed up your workflow and save you hours of wasted time. More than that, they could be the difference between being able to complete a project on time or not!