After Effects Expression – Proximity

Thought I’d share a fun experiment for anyone who wants to learn cool after effects expressions! (You can download the file here.)

The following animation uses just 3 keyframes:

Abstract light animation expression

Everything in this animation is based on the position of a layer that I’ve named “Target”. When I move the target layer, things scale up as it comes near.

You can see here how the target layer effects the circle:

After effects proximity expression.gif

One last example here of the control/target layer effecting multiple circles:

3d Proximity after effects expression.gif

 

All these examples are available for download here.
I’ll also put the expression below for those of you who like to copy/paste:

//The target is your main layer. This is the layer that controls everything else.
//Replace the word “Target” with whatever you’ve named your main control layer
target = thisComp.layer(“Target”);

//How far away your target layer is from this layer.
dist
= Math.floor( length(position, target.position) );

//when the this object is closest, this is how big it can get?

maxSize = 33;

//How small should your layer get?

minSize
= 10

//how far can the target be before this layer starts to get bigger.

range = target.effect(“range”)(“Slider”);

// how fast the layer starts to scale up once the target is in range.

sensitivity = target.effect(“sensitivity”)(“Slider”);

//”linear” allows us to put in all our parameters and get a value back 
scle
= linear(dist, range, sensitivity, maxSize, minSize);

//The final result
[scle/2, scle/2];

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s