ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Hovering Scale Animation

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Francis Saldaña
Hovering Scale Animation
on Apr 26, 2019 at 3:48:11 am

Hi! I am working on a video that micmics something like selecting an object with a mouse cursor. It should go like when you hover the arrow on top of the object it should scale up a bit. I did that using this expression:

point = thisComp.layer("Motion Controller").transform.position; //controlls the cursor
housePoint = thisLayer.sampleImage(point, [.5,.5])[3]; //produces a value of "1" when the null is over this layer or "0" when not.

houseScale = ease(housePoint, 0,1,60,70);
[houseScale,houseScale]


But this just jumps the value of the scale from 60% to 70%. What I want is have like an ease or animation when scaling up. I would really appreciate your help. Thank you so much!


Return to posts index

Kalleheikki Kannisto
Re: Hovering Scale Animation
on Apr 26, 2019 at 6:59:29 am

Starting with the theory, it would go like this:

You want to use either the distance of the cursor from the (center of the) object OR the time of how long the cursor has been over the object (or how long since it left the object) to control the scaling.

Distance to the center of the object would be easier. Calculate the distance and then remap that distance to the scale with the linear() expression. Linear() is a very handy expression to know. For a bit more advanced version, replace with the ease() expression. Probably not necessary here.

If you rather have the scaling happen when approaching the edge of the object, you can, to a degree, simulate that by using sourceRectAtTime() to find out the width and height of the object and include those in calculating the distance of the cursor from the containing rectangle of the object.

Time is more involved. You need a loop that counts backwards from current frame, one frame at a time, up to the length of the transition, and checks whether the cursor is over the object or not. As a result you either get the number of frames the cursor has been over the object or when it has left the object or that it has not been over the object at all. Then you can use the linear() or ease() expression to change the scale based on time. Definitely more complex a procedure.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Kalleheikki Kannisto
Re: Hovering Scale Animation
on Apr 26, 2019 at 7:07:16 am

In case that proves too difficult, I realized there's an easier way to do this, which I occasionally use. You can use your original expression for the scale, but apply it to a duplicate of your layer. Then convert the expression to keyframes and finally add a smooth() expression to the layer's scale (keeping the keyframes). It will give you a "baked" animation with a smoothing expression applied to the scaling over time. Keep the original layer with the editable expression in case you need to adjust, just hide it.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index


Francis Saldaña
Re: Hovering Scale Animation
on Apr 26, 2019 at 9:10:25 am

Wow. I didn't think it would be that complex. I need to study first the functions needed for the process that you gave. I think it would be faster now if I would just animate them manually. But I definitely need this for my upcoming project cause that has a lot of objects to hover around. Thank you so much Kalleheikki.


Return to posts index

Kalleheikki Kannisto
Re: Hovering Scale Animation
on Apr 27, 2019 at 10:42:41 am
Last Edited By Kalleheikki Kannisto on Apr 27, 2019 at 10:46:44 am

You can always try the easy way (distance of the cursor from the anchor point of the layer) first and if it works, you don't need to bother with the more complicated one that takes the layer dimensions into account.

The simple version is really quite simple.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]