Jump to content
Sign in to follow this  
Beaver

5 expressions that will change your life

Recommended Posts

These expressions save so much time, you might get home earlier tonight just by reading this post. If you've ever animated these sorts of things manually, you'll know what I mean. Most will need to be tweaked to your specific needs, but it's just a matter of playing with the numbers a little, and understanding how they'll change your animation. Here's the goods:

 

Jumpy Wiggle 1 makes wiggle skip and hold rather than move fluidly.

// Jumpy Wiggle 1 (moves at a random FPS)
v=wiggle(5,50);
if(v < 50)v=0;
if(v > 50)v=100;
v

 

Jumpy Wiggle 2 is similar to 1, but works at a defined FPS so your "jump" will happen at a regular pace.

// Jumpy Wiggle 2 (moves at a defined FPS)
fps=5; //frequency
amount=50;  //amplitude
wiggle(fps,amount,octaves = 1, amp_mult = 0.5,(Math.round(time*fps))/fps);

 

Inertial Bounce is like making your moves "rubbery." Layers will overextend, then settle into place on position and rotation keyframes.

// Inertial Bounce (moves settle into place after bouncing around a little)
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time - key(n).time;
}

if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
amp = .05;
freq = 4.0;
decay = 2.0;
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
value;
}

 

Sometimes you just want something to move constantly without keyframing it. Use throw.

// Throw (move at a constant speed without keyframes)
veloc = -10; //horizontal velocity (pixels per second)
x = position[0] + (time - inPoint) *veloc;
y = position[1];
[x,y]

 

Same as throw, but for rotation.

// Spin (rotate at a constant speed without keyframes)
veloc = 360; //rotational velocity (degrees per second)
r = rotation + (time - inPoint) *veloc;
[r]

 

A shoutout to the brilliant folks at aenhancers.com who provided in whole or in part the basis for all of these expressions.

Share this post


Link to post
Share on other sites

You're underselling inertial bounce - you can put it in your scale parameter for squash and stretch bounciness, I even tried it with CC Bend It, to create a bendy rubber stick (apply it to the bend parameter, obviously)

Perhaps it could be used with puppet pins to create secondary motion in cartoon animation (I haven't tried this yet)?

Share this post


Link to post
Share on other sites

nice.

 

On throw, I wonder how you'd make it loop across the screen on one axis (or both),

so that when the left most edge exited the frame, it would re-emerge on the right side, while still exiting on the left.

Kinda like an offset loop, but with expressions.

 

 

hmmmmm?

Share this post


Link to post
Share on other sites
nice.

On throw, I wonder how you'd make it loop across the screen on one axis (or both),

so that when the left most edge exited the frame, it would re-emerge on the right side, while still exiting on the left.

Kinda like an offset loop, but with expressions.

hmmmmm?

 

You'd have to stick with offset. An expression can't make an object appear in two places at the same time.

 

But, if it can leave the screen, you could do this:

 

startPos = 250;
endPos = thisComp.width;
end = thisComp.duration;
x = linear(time, 0, end, -startPos, endPos);
[x, value[1]]

 

Made an edit.. "startPos" has to be a sort of fudge factor. If you are using AE text, expressions cannot retrieve the width of a text layer. But, if you're layer has a fixed with, then you can use:

 

startPos = thisLayer.width;
endPos = thisComp.width;
end = thisComp.duration;
x = linear(time, 0, end, -startPos, endPos);
[x, value[1]]

Edited by graymachine

Share this post


Link to post
Share on other sites
havent really used expressions in AE much.

want to test these though.

Do I create a new camera and alt click on it's position property and then copy one of these codes?

 

You put them on any property you want. The golden rule with expressions is:

 

Expressions ONLY do what you can otherwise do with keyframes. Their purpose is to simplify otherwise complex keyframe animation.

Share this post


Link to post
Share on other sites
You put them on any property you want. The golden rule with expressions is:

 

Expressions ONLY do what you can otherwise do with keyframes. Their purpose is to simplify otherwise complex keyframe animation.

 

Well said, Harry, and great thread, it's spurred me to share one of my recent effects involving expressions:

a little while back I needed to make an oscillating or 'crenelated' spiral path:

 

http://members.shaw.ca/pdebay/cren_spiral.png

 

With the help of, who else, Dan Ebberts, and nab's Create Custom Effect script, I made this into an editable effect - it's tied to the Write-On effect, but you can easily pick-whip the output to any positional-based parameter.

 

It was created for a particular purpose (and perhaps limited in its use), but in the spirit of community, the archive is here:

http://members.shaw.ca/pdebay/PDB_Crenelat...ral_beta0.1.zip

 

the archive contains the AE7 .ffx preset, as well as the text you'll have to copy and paste into your "PresetEffects.xml" - if you feel comfortable tweaking that file, of course. As always, I recommend backing up your work and your .xml file.

 

Happy spiralling,

Peter Debay

Freelance After Effects Motion Graphics & Compositing

http://members.shaw.ca/pdebay

Share this post


Link to post
Share on other sites

I would be remiss if I didn't post the position expression for those not wanting to download the custom effect:

 

center=[thisComp.width/2,thisComp.height/2];
rMax = 240; //maximum radius
decay = 0.3; //decay
freq = 6; //frequency
aStart = 0; //start angle offset
aRate = 220; //rotation rate
offsetFactor = 12; //smoothness

r = rMax/Math.exp(time*decay);
a = degreesToRadians(aStart + aRate*time);
offset = (r/offsetFactor)*Math.sin(freq*time*Math.PI*2);
center + [Math.cos(a),Math.sin(a)]*(r + offset);

 

Happy spiralling,

Peter Debay

Freelance After Effects Motion Graphics & Compositing

http://members.shaw.ca/pdebay

Edited by pdeb

Share this post


Link to post
Share on other sites

Thank you ! very much!

 

One question: if my object rotation and or position is linked to other object...how should i put this to work together ?

 

the object rotation is linked like this : thisComp.layer("Red Solid 2").transform.rotation

 

what changes should i put to your code ? =) thank you

 

// Inertial Bounce (moves settle into place after bouncing around a little)

n = 0;

if (numKeys > 0){

n = nearestKey(time).index;

if (key(n).time > time){

n--;

}

}

if (n == 0){

t = 0;

}else{

t = time - key(n).time;

}

 

if (n > 0){

v = velocityAtTime(key(n).time - thisComp.frameDuration/10);

amp = .05;

freq = 4.0;

decay = 2.0;

value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);

}else{

value;

}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×