You are on page 1of 29

BB Formatted: Strikethrough

Formatted: Left: 1.77"

maifgootakesilsys192.linear] Formatted: Strikethrough


dfe
Formatted: Strikethrough

Formatted: Strikethrough
IF YOU WANT TO ADD
oi

EXPRESSIONS, DO IT AT
THE BOTTOM OF THE
DOCUMENT
Inertial Bounce iInertial Bouns like making your moves "rubbery." Layers will Formatted: Strikethrough
overextend, then settle into place on position and rotation keyframes.
Formatted: Strikethrough
// Inertial Bounce (moves settle into place after bouncing around a little)
Formatted: Strikethrough
cccccc amp = .1;
freq = 2.0; Formatted: Space After: 0 pt, Line spacing: Multiple
decay = 2.0; 1.15 li
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}}
if (n == 0){ t = 0;
}else{sdadaasd
t = time - key(n).timevbvf;
}
if (n > 0 && t < 1){
v = velocityA amp = .1;
freq = 2.0;
decay = 2.0;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}}
if (n == 0){ t = 0;
}else{sdadaasd
tTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*
4Math.PI)/Math.exp(decay*t); }else{value} Formatted: Strikethrough

amp = .1; Formatted: Strikethrough


freq = 2.0;
decay = 2.0;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
amp = .1;
freq = 2.0 ;
decay = 2.0;
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 && t < 1){
v = velocityAtTime(key(n).time amp = .1;
freq = 2.0;
decay = 2.0;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}}
- thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}
//Takes 3d space of layer and converts to 2d screen space Formatted: Strikethrough

thisComp.layer("Light 1").toComp([0,0,0]); Formatted: Strikethrough

//Takes 2D position (not world space) and uses it to position 3D objects in screen Formatted: Strikethrough

L = thisComp.layer("Null 1"); Formatted: Strikethrough


value + fromCompToSurface(L.position);
Formatted: Strikethrough

le Formatted: Strikethrough
3Jumpy Wiggle 1 makes wiggle skip and hold rather than move fluidly. Formatted: Strikethrough

Formatted: Strikethrough

// Jumpy Wiggle 1 (moves at a random FPS) Formatted: Strikethrough


v=wiggle(5,50);
Formatted: Strikethrough

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 Formatted: Strikethrough
at a regular pace.

// Jumpy Wiggle 2 (moves at a )defined FPS) Formatted: Strikethrough


fps=5; //frequency
amount=50; //amplituder
wiggle(fps,amount,octaves = 1, amp_mult = 0.5,(Math.round(time*fps))/fps);

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

// Throw (move at a constant speed without keyframes) Formatted: Strikethrough


veloc = -10; //horizontal velocity (pixels per second)
x = position[0] + (time - inPoint) *veloc;
y = position[1];
z = position[2]; Formatted: Strikethrough
[x,y,z]

Create an eased repeating motion in constant increments: Formatted: Strikethrough

f = timeToFrames(time); Formatted: Strikethrough


line = Math.floor(f/25);
Formatted: Strikethrough
pix = Math.min(f%25,10);
pixe = ease(pix, 0, 10, 0, 60); Formatted: Strikethrough
value - [0, line*60+pixe] Formatted: Strikethrough
Formatted: Strikethrough
to make it go up or down just change: value - [0, line*60+pixe] to value +[...
Formatted: Strikethrough
Spin is the same as throw, but for rotation. Formatted: Strikethrough

// Spin (rotate at a constant speed without keyframes) Formatted: Strikethrough


zveloc = 360; //rotational velocity (degrees per second)
r = rotation + (time - inPoint) *veloc;
[r]

//Autofade: Add to opacity Formatted: Strikethrough


transition = 20; // transition time in frames
Formatted: Strikethrough
if (marker.numKeys<2){
tSecs = transition / ( 1 / thisComp.frameDuration); // convert to seconds
linear(time, inPoint, inPoint + tSecs, 0, 100) - linear(time, outPoint - tSecs, outPoint, 0, 100)
}else{
linear(time, inPoint, marker.key(1).time, 0, 100) - linear(time, marker.key(2).time, outPoint, 0,
100)
}

//Snap zoom in and out: apply to scale Formatted: Strikethrough


snapScale = 300; //percent of scale to zoom

trans = 4; // transition time in frames


trans = trans * thisComp.frameDuration;
inTrans = easeOut(time, inPoint, inPoint + trans, [snapScale,snapScale], [0,0]);
outTrans = easeIn(time, outPoint, outPoint - trans, [0,0], [snapScale, snapScale]);
value+ inTrans + outTrans

// Y Axis Jitter Formatted: Strikethrough

probability = 8 ; //higher is less likely Formatted: Strikethrough


pos = 50;
val = random(-probability-2, 1); Formatted: Strikethrough
m = clamp(val, 0, 1);
y = wiggle(10, pos*m)-position;
value + [0, y[1]]

3D layer invisible while facing backwards to camera (use on Opacity): Formatted: Strikethrough
if (toCompVec([0, 0, 1])[2] > 0 ) value else 0
Formatted: Strikethrough

Parent Puppet pin to Null (there is a script on AEscripts for this also I believe, haven't Formatted: Strikethrough
used it):
n=thisComp.layer("NullObject_Name"); Formatted: Strikethrough
nullpos=n.toComp(n.anchorPoint); Formatted: Strikethrough
fromComp(nullpos);
Formatted: Strikethrough
Numbers: Formatted: Strikethrough
Add a slider and name to 'Value'
Formatted: Strikethrough

places = 3; //number of decimal places desired Formatted: Strikethrough


val = effect("Value")("Slider"); //sub in the name of your slider here Formatted: Strikethrough
factor = Math.pow(0.1, places) ; Formatted: Strikethrough
sign = "";
Formatted: Strikethrough
if (val < 0) sign = "-";
Formatted: Strikethrough
val = Math.abs(val); Formatted: Strikethrough
whole = Math.floor(val);
Formatted: Strikethrough
fraction = "" + Math.round((val - whole)/factor)*factor;
Formatted: Strikethrough
for (fraction; fraction.length < places+2; fraction+="0"); Formatted: Strikethrough

sign + whole + "." + fraction.substring(2, places+2) Formatted: Strikethrough

Position from layer above Formatted: Strikethrough


thisComp.layer(index - 1).transform.position Formatted: Strikethrough
Formatted: Strikethrough
Number of decimal places
//--Begin Expression Formatted: Strikethrough
Formatted: Strikethrough
nums = thisComp.layer("Deep Lime Green Solid 1").effect("Slider Control")("Slider"); Formatted: Strikethrough
numOfPlaces = 3;
Formatted: Strikethrough
//--Do not modify below this line
Formatted: Strikethrough
function roundTo(number, places) Formatted: Strikethrough
{
Formatted: Strikethrough
num = Math.round ( Math.pow(number, places) );
}NUMBER ROUNDING Formatted: Strikethrough
myNumber = 23.3453255243697978; Formatted: Strikethrough
round(myNumber, 2);
Formatted: Strikethrough

function round(aNum, dP) { Formatted: Strikethrough


return(Math.round(aNum*Math.pow(10, dP))/Math.pow(10, dP)); Formatted: Strikethrough
}
Formatted: Strikethrough
num /= Math.pow(10, places);
return num; Formatted: Strikethrough
} Formatted: Strikethrough
Formatted: Strikethrough
roundTo(nums, numOfPlaces)
Formatted: Strikethrough
//--End expression Formatted: Strikethrough
Formatted: Strikethrough
Round decimal
Math.round(your_decimal_number_here) Formatted: Strikethrough
Formatted: Strikethrough
RANDOM MOVEMENT
Formatted: Strikethrough
//Returns two values by default; [x-pos. y-pos]
segDur = .5;// duration of each "segment" of random motion Formatted: Strikethrough
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
Formatted: Strikethrough
maxVal = [0.9*thisComp.width, 0.9*thisComp.height];
Formatted: Strikethrough
seed = Math.floor(time/segDur); Formatted: Strikethrough
segStart = seed*segDur;//Returns two values by default; [x-pos. y-pos]
Formatted: Strikethrough
segDur = .5;// duration of each "segment" of random motion
Formatted: Strikethrough
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height]; Formatted: Strikethrough
Formatted: Strikethrough
seed = Math.floor(time/segDur);
Formatted: Strikethrough
segStart = seed*segDur;
seedRandom(seed,true); Formatted: Strikethrough
startVal = random(minVal,maxVal); Formatted: Strikethrough
seedRandom(seed+1,true);
Formatted: Strikethrough
endVal = random(minVal,maxVal);
ease(time,segStart,segStart + segDur, startVal, endVal); Formatted: Strikethrough
Formatted: Strikethrough
Time Output
Formatted: Strikethrough
//Contains rounding + always display 2 digits
Formatted: Strikethrough
//Contains rounding + always display 2 digits Formatted: Strikethrough
Formatted: Strikethrough
min = Math.floor(time);
strMin = String(min); Formatted: Strikethrough
if(min < 10){ Formatted: Strikethrough
strMin = '0' + strMin;
Formatted: Strikethrough
}
Formatted: Strikethrough
sec = Math.round(((time) - min)*100); Formatted: Strikethrough
strSec = String(sec);
Formatted: Strikethrough
if(sec < 10){
strSec = '0' + strSec; Formatted: Strikethrough
} Formatted: Strikethrough
Formatted: Strikethrough
"18:22:" + strMin + ":" + strSec
Formatted: Strikethrough
min = Math.floor(time); Formatted: Strikethrough
strMin = String(min); Formatted: Strikethrough
if(min < 10){
Formatted: Strikethrough
strMin = '0' + strMin;
} Formatted: Strikethrough
Formatted: Strikethrough
sec = Math.round(((time) - min)*100);
Formatted: Strikethrough
strSec = String(sec);
if(sec < 10){ Formatted: Strikethrough
strSec = '0' + strSec; Formatted: Strikethrough
}
Formatted: Strikethrough

"18:22:" + strMin + ":" + strSec Formatted: Strikethrough


Formatted: Strikethrough
Formatted: Strikethrough
Formatted ...
Formatted ...
Formatted ...
Random Letters
//Begin expression Formatted ...
numOfLetters = 25 Formatted ...
; //Modify me
Formatted ...
useSpaces = true; //Modify me
changeEveryFrame = true; //Modify me Formatted ...
Formatted ...
//Don't modify below this line
Formatted ...
seedRandom(index, !changeEveryFrame) Formatted ...
//-- Formatted ...
function genLetter( ) {
Formatted ...
r = random(65, 90);//from a to z
return String.fromCharCode( r ); Formatted ...
} Formatted ...
s = "";
Formatted ...
for(i = 0; i < numOfLetters; i++)
{ Formatted ...
s += genLetter(); Formatted ...
if(useSpaces) Formatted ...
s += " ";
Formatted ...
}
s Formatted ...
//End expression Formatted ...
Formatted ...
Loop
Formatted ...
//Looping Script
Formatted ...
freq = 0.6;
amp = 5; Formatted ...
loopTime = 10; Formatted ...
t = time % loopTime; Formatted ...
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime); Formatted ...
linear(t, 0, loopTime, wiggle1, wiggle2); Formatted ...
Formatted ...

Random Position HOLD Formatted ...


Formatted ...
holdTime = .5; //time to hold each position (seconds)
Formatted ...
minVal = [0.1*thisComp.width, 0.1*thisComp.height];
maxVal = [0.9*thisComp.width, 0.9*thisComp.height]; Formatted ...
Formatted ...
seed = Math.floor(time/holdTime);
Formatted ...
seedRandom(seed,true);
random(minVal,maxVal) Formatted ...
Smooth Keyframes Formatted ...
smooth(width = .2, samples = 5, t = time)
Formatted ...
Formatted ...
Creating Trails Formatted: Strikethrough
,,delay = 5; //number of frames to delay
Formatted: Strikethrough

d = delay*thisComp.frameDuration*(index - 1); Formatted: Strikethrough


thisComp.layer(1).position.valueAtTime(time - d);
Formatted: Strikethrough

OR Formatted: Strikethrough
thisComp.layer(index+1).transform.position.valueAtTime(time-.1);oeqydz2K16
Formatted: Strikethrough

Formatted: Strikethrough

Wiggle X axis only Formatted: Strikethrough

[wiggle(5,30)[0],value[1]]; Formatted: Strikethrough

Wiggle Y axis only Formatted: Strikethrough

[value[0],wiggle(1,100)[1]]; Formatted: Strikethrough

Smooth Wiggle Formatted: Strikethrough


http://forums.adobe.com/message/1799293#1799293
Formatted: Strikethrough

seedRandom(time*5); Formatted: Strikethrough


wiggle(0,100);
Formatted: Strikethrough
seedRandom(time*5);
wiggle(0,100) Formatted: Strikethrough
//Copy size and rescale from layer above Formatted: Strikethrough
thisComp.layer(index - 1).scale-[7,7];
Formatted: Strikethrough
Formatted: Strikethrough

//Copy rotation from layer below and rotate 22.5 Formatted: Strikethrough
thisComp.layer(index+1).transform.rotation+22.5;
Formatted: Strikethrough

//Copy position from layer above Formatted: Strikethrough


thisComp.layer(index-1).position;
Formatted: Strikethrough

Keep x at 960, move Y X time * 100 pixels Formatted: Strikethrough

[960, position[1]+time*-100]; Formatted: Strikethrough

Lock a layer to the exact centre of the comp (very useful for rotoscoping where you Formatted: Strikethrough
accidentally nudge the layer all the time)
Formatted: Strikethrough
//On the (2D, comp size) layer’s Position:
Formatted: Strikethrough
[comp.Length/2, comp.Height/2];
Formatted: Strikethrough
DEFINITION Formatted: Strikethrough
Formatted: Space Before: 24 pt, After: 6 pt, Line
spacing: Multiple 1.15 li
Google Docs
Formatted: Right: 0", Space After: 0 pt
Formatted: Strikethrough
Formatted: Space After: 0 pt, Line spacing: Multiple
1.15 li
Formatted: Strikethrough
Posted by: Margaret Rouse
WhatIs.com Formatted: Strikethrough
Formatted: Space Before: 0 pt, After: 0 pt
Formatted: Strikethrough
Formatted: Strikethrough
Time delay from layer above
Formatted: Strikethrough
thisComp.layer(index+1)t.transform.position.valueAtTime(time-.1)
Formatted: Left, Indent: Hanging: 0.25", Outline
Wiggle in one direction only numbered + Level: 1 + Numbering Style: Bullet +
Wiggle Y Only: Aligned at: 0.75" + Indent at: 0.5"
Formatted: Strikethrough
[value[0],wiggle(1,100)[1]]
Formatted: Strikethrough

Wiggle X Only: Formatted: Strikethrough


Formatted: Strikethrough
[wiggle(5,30)[0],value[1]] Formatted: Strikethrough

Wiggle X and Y separately: Formatted: Strikethrough


Formatted: Strikethrough
[wiggle(5,30)[0],wiggle(1,100)[1]] Formatted: Strikethrough
Formatted: Strikethrough

vLoop Types Formatted: Strikethrough


loopOut("pingpong") // ABCD(CBABCDCBA) Formatted: Strikethrough
loopOut("continue") // ABCD(EFGHIJKL)
Formatted: Strikethrough
loopOut("Cycle") // ABCD(ABCDABCD)
Formatted: Strikethrough
Formatted: Strikethrough
Range Mapping
Formatted: Strikethrough
input = effect("Slider Control")("Slider");
inputLow = 0; Formatted: Strikethrough
inputHigh = 100; Formatted: Strikethrough
outputLow = -100;
Formatted: Strikethrough
outputHigh = 100;
Formatted: Strikethrough
linear(input,inputLow,inputHigh,outputLow,outputHigh) Formatted: Strikethrough

For when you want burn in text to automatically display the layer name (i.e. render out Formatted: Strikethrough
tiff sequence first, then making a QT w/ name burn in).

Make text layer, add expression to 'source text'. Formatted: Strikethrough

function pad(number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; Formatted: Strikethrough
} return str; } var theLayerName = thisComp.layer(index+1).name; var theLayerNameSplit =
theLayerName.split('.'); theLayerNameSplit[0];

To change which layer is read for the name, change the (index+1) to (index+2) and so on. Formatted: Strikethrough

Counting numbers with comma: Formatted: Strikethrough

startCount = 0; Formatted: Strikethrough


endCount = 11689;
Formatted: Strikethrough
countDur = 1.2;
s = "" + Math.round(linear(time,0,countDur,startCount,endCount)); Formatted: Strikethrough
Formatted: Strikethrough
if (s.length > 3){
Formatted: Strikethrough
s.substr(0, s.length -3) + "," + s.substr(-3);
}else{ Formatted: Strikethrough
s Formatted: Strikethrough
}
Formatted: Strikethrough
Formatted: Strikethrough
Oscillate Rotation Formatted: Strikethrough

Use Expression Control angles or sliders for “ from”, “to”, and an Expression Formatted: Strikethrough
Control slider assigned to “period” for fine control. You can apply these to any layer.
Formatted: Strikethrough
Change “linear” to “ease” for smoother interpolation.
by Michael Natkin & Brian Maffitt Formatted: Strikethrough
Formatted: Strikethrough

Formatted: Strikethrough
from = -45; //one end of your oscillation
to = 45; //the other end of your oscillation Formatted: Strikethrough
period = 1.5; //time between oscillation points (multiply by 2 for a round trip) Formatted: Strikethrough
t = time % (period * 2);
Formatted: Strikethrough
if (t > period) t = 2 * period - t;
linear(t, 0, period, from, to) Formatted: Strikethrough
Formatted: Strikethrough
Formatted: No widow/orphan control
Grayscale Value to x,y Data
(x&y outputs will range from 0-100) Formatted: Strikethrough
Formatted: Strikethrough
Formatted ...
sourceLayer = thisComp.layer(“layer");
sampleSize = [1,1]; Formatted ...
samplePoint = transform.position; Formatted ...
color= sourceLayer.sampleImage(samplePoint,sampleSize);
Formatted ...
x=color[0]*100
y=color[0]*100 Formatted ...
[x,y] Formatted ...
Formatted ...

Percentage Counter With Slider Control: Formatted ...


Formatted ...
islider = effect("Slider Control")("Slider"); Formatted ...
numDecimals = 0;
Formatted ...
commas = false;
dollarSign = false; Formatted ...
percentSign = true; Formatted ...
s = slider.value.toFixed(numDecimals);
Formatted ...
prefix = "";
suffix = ""; Formatted ...
if (s[0] == "-"){ Formatted ...
prefix = "-";
Formatted ...
s = s.substr(1);
} Formatted ...
if(dollarSign) prefix += "$"; Formatted ...
if(percentSign) suffix = "%";
Formatted ...
if (commas){
decimals = ""; Formatted ...
if (numDecimals > 0){ Formatted ...
decimals = s.substr(-(numDecimals + 1));
Formatted ...
s = s.substr(0,s.length - (numDecimals + 1));
} Formatted ...
outStr = s.substr(-s.length, (s.length-1)%3 +1); Formatted ...
for (i = Math.floor((s.length-1)/3); i > 0; i--){ Formatted ...
outStr += "," + s.substr(-i*3,3);
} Formatted ...
prefix + outStr + decimals + suffix; Formatted ...
}else{ Formatted ...
prefix + s + suffix;
Formatted ...
}
Formatted ...
Formatted ...
Formatted ...
Formatted ...
Formatted ...
Formatted ...
Rounding Numbers:
Formatted ...
Math.round(value) Formatted ...
● rounds the number Formatted: Strikethrough
Formatted: Indent: Hanging: 0.25", Outline numbered
Math.ceil(value)
+ Level: 1 + Numbering Style: Bullet + Aligned at:
● rounds up 0.75" + Indent at: 0.5", No widow/orphan control
Formatted: No widow/orphan control
Math.floor(value)
● rounds down Formatted: Strikethrough
Formatted: Strikethrough
Scaling 3d layers while moving actg 3d laive camera:
Formatted: Indent: Hanging: 0.25", Outline numbered
+ Level: 1 + Numbering Style: Bullet + Aligned at:
cam = thisComp.activeCamera;
0.75" + Indent at: 0.5", No widow/orphan control
distance = length(sub(position, startPoint.position));
scale * distance / cam.zoom; Formatted: No widow/orphan control
Formatted: Strikethrough
Formatted: Strikethrough
Formatted: Indent: Hanging: 0.25", Outline numbered
+ Level: 1 + Numbering Style: Bullet + Aligned at:
0.75" + Indent at: 0.5", No widow/orphan control

Value change over time Formatted: Strikethrough


Formatted: Strikethrough
value = "Hello"; Formatted: Strikethrough
if (time >= 1){
value = "Goodbye" Formatted: Strikethrough
} Formatted: Strikethrough
Formatted: Strikethrough
Formatted: Strikethrough

Smooth Credits (Or constant motion on the Y Axis) Formatted: Strikethrough


Formatted: Strikethrough
Apply this to position and then move the anchor point to position your credits. Change S to
Formatted: Strikethrough
change the speed or direction of the credits
t = time; Formatted: Strikethrough
fr = t/thisComp.frameDuration; Formatted: Strikethrough
x = value [0];
Formatted: Strikethrough
s = -6; //Speed in pixels per frame
[x, fr*s] Formatted: Strikethrough
Formatted: Strikethrough
Formatted: Strikethrough

Center the Anchor Point in a text layer - automatically adjusts with changes Formatted: Strikethrough

value-[0,this.sourceRectAtTime(time).hei-ght/2] Formatted: Strikethrough


Formatted: Strikethrough
The same, but both axis
Formatted: Strikethrough
x = this.sourceRectAtTime(time).left+this.sourceRectAtTime(time).width/2;
y = this.sourceRectAtTime(time).top+this.sourceRectAtTime(time).height/2; Formatted: Strikethrough
Formatted: Strikethrough
Formatted ...
Formatted ...
Formatted ...
[x, y]
Formatted ...
Formatted ...
Random Grid Movement
Formatted ...
http://www.motionscript.com/expressions-lab-ae65/random-grid-movement.html
Formatted ...
move objects randomly along a grid to a new position on the grid.
Formatted ...
Try applying this expression to the position property of a square solid and then duplicated the solid a
bunch of times. Formatted ...
Note that the number of rows is calculated from the number of columns and that the objects come to
Formatted ...
rest at the intersection of rows and columns.
Adjust the number of columns, hold time, minimum and maximum cycle time to suit your needs. Formatted ...
Formatted ...
Formatted ...
columns = 23.41; //number of columns in grid
tHold= .2; //hold time (must be less than tmin) Formatted ...
tMin = 1; //minimum cycle time (can't be zero) Formatted ...
tMax = 1.2 //maximum cycle time
Formatted ...
gap = this_comp.width/columns; Formatted ...
origin = [gap,gap]; Formatted ...
xGrid = columns - 1;
Formatted ...
yGrid = Math.floor(this_comp.height/gap) - 1;
Formatted ...
start = 0; Formatted ...
end = 0;
Formatted ...
j = 1;
Formatted ...
while (time >= end){ Formatted ...
j += 1; Formatted ...
seedRandom(j,true);
Formatted ...
start = end;
end += random(tMin,tMax); Formatted ...
} Formatted ...
targetX = Math.floor(random(0,xGrid));
Formatted ...
targetY = Math.floor(random(0,yGrid));
seedRandom(j-1,true); Formatted ...
x = random(); //this is a throw-away value Formatted ...
oldX = Math.floor(random(0,xGrid));
Formatted ...
oldY = Math.floor(random(0,yGrid));
Formatted ...
if(targetX == oldX && targetY == oldY){ Formatted ...
origin + [oldX,oldY]*gap;
Formatted ...
}else if (time - start < tHold){
origin + [oldX,oldY]*gap; Formatted ...
}else{ Formatted ...
deltaX = Math.abs(targetX - oldX);
Formatted ...
deltaY = Math.abs(targetY - oldY);
xTime = (end - start - tHold)*(deltaX/(deltaX + deltaY)); Formatted ...
yTime = (end - start - tHold)*(deltaY/(deltaX + deltaY)); Formatted ...
Formatted ...
Formatted ...
if (time < start + tHold + xTime){
startPos = origin + [oldX,oldY]*gap; Formatted ...
targetPos = origin + [targetX,oldY]*gap; Formatted ...
easeOut((time - start - tHold)/xTime, startPos, targetPos);
Formatted ...
}else{
startPos = origin + [targetX,oldY]*gap; Formatted ...
targetPos = origin + [targetX,targetY]*gap Formatted ...
easeIn((time - start - tHold - xTime)/yTime, startPos, targetPos);
Formatted ...
}
} Formatted ...
Formatted ...
Formatted ...

Offset one axis separately for linked comps in 3D space Formatted ...
Formatted ...
thePos = comp("MainComp").layer("Your3DLayer").transform.position; Formatted ...
[thePos[0]+offset, thePos[1]+offset, thePos[2]+offset]
//NUMBER COUNTDOWN SCRIPT (WITH COMMAS) Formatted ...
To get a number to countdown (from say 256,000 to 152,000 with commas, no decimal) Formatted ...
follow these steps. (I didn't write most of the expression, got it from a website but it works Formatted ...
great)
Formatted ...
1. Create a expression control slider and use the slider control effect to animate number. Formatted ...
Enter the actual value instead of using the slider for numbers larger than one hundred. Formatted ...
Simply key frame the effect and use the character editor to format the text. (Goes as high as
Formatted ...
1,000,000)
Formatted ...
Right-click on an Expression Slider>Edit Value to set the minimum and maximum it Formatted ...
can slide to
Formatted ...
For higher numbers i.e billions just add in a multiply value after the first line:
var num = effect("Slider Control")("Slider") * 10000000 Formatted ...
Formatted ...
Expression:
Formatted ...

var num = effect("Slider Control")("Slider") Formatted ...


num = Comma(num); Formatted ...
[num] Commented [1]:
Commented [2]:
function Comma(number)
{ Commented [3]:
number = '' + Math.round(number); Formatted ...
if (number.length > 3)
Formatted ...
{
var mod = number.length % 3;IMPACT BOUNCE Formatted ...
var output = (mod > 0 ? (number.substring(0,mod)) : ''); Formatted ...
for (i=0 ; i < Math.floor(number.length / 3); i++)
Formatted ...
{
if ((mod == 0) && (i == 0)) Formatted ...
output += number.substring(mod+ 3 * i, mod + 3 * i + 3); Formatted ...
else Formatted: Strikethrough
output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
Formatted: Strikethrough
}
return (output); Formatted: Strikethrough
} Formatted: Strikethrough
else return number;
Formatted: Strikethrough
}
Formatted: Strikethrough
//Counting numbers with comma: Formatted: Strikethrough
Formatted: Strikethrough
startCount = 0;
endCount = 11689; Formatted: Strikethrough
countDur = 1.2; Formatted: Strikethrough
s = "" + Math.round(linear(time,0,countDur,startCount,endCount)); Formatted: Strikethrough

if (s.length > 3){ Formatted: Strikethrough


s.substr(0, s.length -3) + "," + s.substr(-3); Formatted: Strikethrough
}else{ Formatted: Strikethrough
s
Formatted: Strikethrough
}
Formatted: Strikethrough
Formatted: Strikethrough
//Variable Quint Interpolation between a/b
Formatted: Strikethrough

a = 0; Formatted: Strikethrough
b = 500; Formatted: Strikethrough
dur = 2;
Formatted: Strikethrough
tension = 5;
Formatted: Strikethrough

tensionAdjust =(Math.ceil(tension/ 2) * 2)-1; Formatted: Strikethrough

function quint(t, b, c, d) { Formatted: Strikethrough


if ((t/=d/2) < 1) return c/2*Math.pow(t, tensionAdjust) + b;
return c/2*((t-=2)*Math.pow(t, tensionAdjust -1) + 2) + b; Formatted: Strikethrough
} Formatted: Strikethrough

t = quint(time - inPoint, 0, 100, dur); Formatted: Strikethrough


value + linear(t, 0, 100, a, b); Formatted: Strikethrough

Anyone wanna start a Wiki for this? Seems too useful not to... Formatted: Strikethrough

IMPACT BOUNCE (bounce back after impact, like slamming doors, Formatted: Strikethrough
bouncing ball) You can apply it to Position, but it will work with any key-
Formatted ...
Formatted ...
Formatted ...
Formatted ...
framed parameters (scale, opacity etc) Formatted ...
Formatted ...
0e = .7;
g = 5000; Formatted ...
nMax = 9; Formatted ...
n = 0;
if (numKeys > 0){ Formatted ...
n = nearestKey(time).index;
if (key(n).time > time) n--;
Formatted ...
} Formatted ...
if (n > 0){
t = time - key(n).time; Formatted ...
v = -velocityAtTime(key(n).time - .001)*e;
Formatted ...
vl = length(v);
if (value instanceof Array){ Formatted ...
vu = (vl > 0) ? normalize(v) : [0,0,0];
}else{ Formatted ...
vu = (v < 0) ? -1 : 1;
Formatted ...
}
tCur = 0; Formatted ...
segDur = 2*vl/g;
tNext = segDur; Formatted ...
nb = 1; // number of bounces Formatted ...
while (tNext < t && nb <= nMax){
vl *= e; Formatted ...
segDur *= e;
tCur = tNext; Formatted ...
tNext += segDur; Formatted ...
nb++
} Formatted ...
if(nb <= nMax){
delta = t - tCur;
Formatted ...
value + vu*delta*(vl - g*delta/2); Formatted ...
}else{
value Formatted ...
}
Formatted ...
}else
value Formatted ...
Formatted ...
Formatted ...
Adjust a single value (parameter) of an effect on a layer, the Formatted ...

further away the layer is from the camera. For this example, it Formatted ...

was applied to 'brightness', to make the layer paler as it Formatted ...


Formatted ...
moves into the distance:
Formatted ...
C = thisComp.activeCamera; Formatted ...
start = 2500;
Formatted ...
end = 25500;
d = length(toWorld(anchorPoint),C.toWorld([0,0,0])); Formatted ...
linear(d,start,end,0,100)
Formatted ...
'start' is the distance the layer is from camera that the expression begins. Formatted
'end' is the distance that the expression reaches maximum effects.
...
Formatted ...
Formatted ...
Formatted ...
Formatted ...
The red numbers indicate the minimum and maximum values returned for any parameter. Change the '100' to '60'
Formatted: Strikethrough
(for example) and 'brightness' will never go higher than 60.

Links position value of effects (corner pin, beam etc etc) to postion of Null Formatted: Strikethrough
(or any layer be it 2d or 3d) Formatted: Space After: 0 pt
Apply this to position value in Effect: Formatted: Strikethrough
target = thisComp.layer("Layer"); // Layer is the layer your want to get the position
Formatted: Strikethrough
value from
fromComp(target.toComp(target.anchorPoint)); Formatted: Strikethrough

Oscillate a value with Math.sin Formatted: Strikethrough

amp = 3; //sine wave amplitude (pixels) Formatted: Strikethrough


freq = 0.5; //oscillations per second Formatted: Strikethrough

x = amp*Math.sin(freq*time*2*Math.PI); Formatted: Strikethrough


[x] Formatted: Strikethrough

Looping Wiggle: Formatted: Strikethrough

freq = 1; Formatted: Strikethrough


amp = 110;
loopTime = 3;
t = time % loopTime;
wiggle1 = wiggle(freq, amp, 1, 0.5, t);
wiggle2 = wiggle(freq, amp, 1, 0.5, t - loopTime);
linear(t, 0, loopTime, wiggle1, wiggle2)

http://www.motionscript.com/design-guide/looping-wiggle.html Formatted: Strikethrough

COUNTING NUMBERS (above 1 Million) Formatted: Strikethrough


Create a new text layer. Add the following expression to source text. Adjust the variables to do
Formatted: Strikethrough
whatever you need.

//begin code Formatted: Strikethrough


Formatted ...
Formatted ...
Formatted ...
Formatted ...
/
startTime = 0; //seconds Formatted ...
Formatted ...
endTime = 5; //seconds
beginCount = 0; Formatted ...
endCount = 2000;
Formatted ...
hasCommas = true;
//--dont modify below here---------------- Formatted ...
function addCommas ( s ){ Formatted ...
if( s.length <= 3 )
return s; Formatted ...
else Formatted ...
return s.substring(0 , 3) + "," + addCommas(s.substring(3, s.length));
Formatted ...
} Formatted ...
function reverse( s ){
newStr = ""; Formatted ...
for(i = s.length-1; i >= 0; i--) Formatted ...
newStr += s.charAt(i)
Formatted ...
return newStr;
} Formatted ...
Formatted ...
val = Math.round (linear(time, startTime, endTime, beginCount, endCount) );
if( hasCommas ) Formatted ...
reverse (addCommas(reverse( val + "" )))
Formatted ...
else
val Formatted ...
Formatted ...
//end code Formatted ...
Formatted ...

// CODE FOR SPLITING LAYERS Formatted ...


Formatted ...
// store all keytime values into arrayKeyTimes;
Formatted ...
Formatted ...
// then take the in and out point values
var inPointValue = layer.inPoint; Formatted ...
var outPointValue = layer.outPoint; Formatted ...
Formatted ...
for (var i = 0; i<=n; i++) { Formatted ...
Formatted ...
layer.duplicate();
layer = thisComp.layer(1); Formatted ...
layer.inPoint = (i == 0) ? inPointValue : arrayKeyTimes[i-1]; Formatted ...
layer.outPoint = (i < n) ? arrayKeyTimes(i) : outPointValue; Commented [4]:
Commented [5]:
}
Formatted ...
Copy the expression, Alt-Click the Scale stopwatch, Paste): Formatted ...
n = 0;
Formatted ...
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n--;
}
}

if (n == 0){
value;
} else {
max_dev=20; // max deviation in pixels
spd=35; //speed of oscillation
decay=10; //how fast it slows down
t = time - marker.key(n).time;
s = max_dev*Math.sin(spd*(t))/Math.exp(decay*t);
value + [s,s];
}
So wherever you place a marker you'll get the old squish and squash. Hit the asterisk (*) key on the Formatted: Strikethrough
numeric pad to drop a marker wherever you are on the timeline.
Formatted: Strikethrough
Note: No marker, no squish and squash. Five markers give five squish and squashes.
Also if you're talking a diferent expression, just drop that in below the }else{. Formatted: Strikethrough
by Mike Clasby (yikesmikes)
Formatted: Strikethrough
Formatted: Strikethrough
More Natural Easing
n = 0; Formatted: Strikethrough
if (numKeys > 0){ Formatted: Strikethrough
n = nearestKey(time).index; Formatted: Strikethrough
if (key(n).time > time){
Formatted: Strikethrough
n--;
Formatted: Strikethrough
}
} Formatted: Strikethrough
if (n == 0){ Formatted: Strikethrough
t = 0; Formatted: Strikethrough
}else{ Formatted: Strikethrough
t = time - key(n).time;
Formatted: Strikethrough
}
if (n > 0){ Formatted: Strikethrough

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


amp = .05; Formatted: Strikethrough
freq = 2.0; Formatted: Strikethrough
decay = 4.0;
Formatted: Strikethrough
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{ Formatted: Strikethrough

value; Formatted: Strikethrough


} Formatted: Strikethrough
Formatted: Strikethrough
Formatted: Strikethrough
Formatted: Strikethrough
Evenly distribute layers between 2 other layers Formatted: Strikethrough
n = thisComp.numLayers;
if (n > 2){ Formatted: Strikethrough
p1 = thisComp.layer(1).transform.position; Formatted: Strikethrough
p2 = thisComp.layer(n).transform.position;
linear(index,1,n,p1,p2) Formatted: Strikethrough
}else{ Formatted: Strikethrough
value
Formatted: Strikethrough
}
Formatted: Strikethrough
SCRIPT TO FLIP OBJECT BASED ON VELOCITY Formatted: Strikethrough
Formatted: Strikethrough
Formatted: Strikethrough
//plug this into SCALE
if (transform.position.velocity[0] <=0){ Formatted: No widow/orphan control

[-value[0], value[1]] Formatted: Strikethrough


} Formatted: Strikethrough
else{ Formatted: Strikethrough
[value[0], value[1]]
Formatted: Strikethrough
}
Formatted: Strikethrough

STEREO CAMERA RIG FIX Formatted: Strikethrough


Formatted: Strikethrough
///////////STEREO RIG FIX - Be sure to set the 3d stereo rig units to pixels, not Formatted: Strikethrough
percentage
Formatted: No widow/orphan control
///// L camera is + N, R camera is - N
N = thisComp.layer("Stereo 3D Controls").effect("3D Glasses")("Scene Convergence"); Formatted: Strikethrough
[value[0] + N, value[1]]
Formatted: Strikethrough
Formatted: Strikethrough
Formatted: Strikethrough
// Layer Autofacing camera Formatted: Strikethrough
Formatted: No widow/orphan control
L = comp("COMPNAME").layer("Camera 1");
Formatted: Strikethrough
u = fromWorldVec(L.toWorldVec([1,0,0]));
Formatted: Strikethrough
v = fromWorldVec(L.toWorldVec([0,1,0]));
Formatted: Strikethrough
w = normalize(fromWorldVec(L.toWorldVec([0,0,1])));
Formatted: Strikethrough

sinb = clamp(w[0],-1,1); Formatted: Strikethrough


b = Math.asin(sinb); Formatted: Strikethrough
cosb = Math.cos(b); Formatted: Strikethrough
if (Math.abs(cosb) > .0005){ Formatted: Strikethrough
c = -Math.atan2(v[0],u[0]);
Formatted: Strikethrough
a = -Math.atan2(w[1],w[2]);
Formatted: Strikethrough
}else{
Formatted: Strikethrough
a = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]); Formatted: Strikethrough
c = 0; Formatted: Strikethrough
} Formatted: Strikethrough
[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)] Formatted: Strikethrough

TIME EXPRESSION Formatted: Strikethrough


Formatted: Normal
countspeed = 1;
Formatted: No widow/orphan control
clockStart = 0;
Formatted: Strikethrough
Formatted: Line spacing: Multiple 1.15 li, No
function times(n){
widow/orphan control
if (n < 10) return "0" + n else return "" + n
}

clockTime = clockStart +countspeed*(time - inPoint);

if (clockTime < 0){


minus = "-";
clockTime = -clockTime;
}else{
minus = "";
}

t = Math.floor(clockTime);
h = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(3).substr(-3);
minus + times(h) + ":" + times(min) + ":" + times(sec) + "." + ms
Formatted: No widow/orphan control

maintain stroke weight speed Formatted: Strikethrough

(modified from Adam Plouff) Formatted: Strikethrough

if(hasParent){ Formatted: Strikethrough


p =Math.abs(parent.scale[0]) ;} Formatted: Strikethrough
else{p=100;} Formatted: Strikethrough
s = Math.abs(transform.scale[0]); Formatted: Strikethrough
scaleFactor = 100/s; Formatted: Strikethrough
PscaleFactor = 100/p; Formatted: Strikethrough
value*scaleFactor*PscaleFactor; Formatted: Strikethrough

PULSE EFFECT
//Change Freq for times per sec and amp for how hard you
want the pulse. Adjust value at bottom to x,x to effect both x
and y values.

freq = 2; Formatted: Strikethrough


amp = 15;
x = amp*Math.sin(freq*time*Math.PI*2); Formatted: Strikethrough
value + [x,0] Formatted: Strikethrough
Formatted: Strikethrough

Move along X over time Formatted: Strikethrough

vel = -25; //speed of the movement. Formatted: Strikethrough


[vel*time+value[0], value[1]] Formatted: Strikethrough

Follow “leader” layer position with added time delay. Formatted: Strikethrough

Put expression in Position of all following layers. Formatted: Strikethrough


● All follower layers must be placed directly beneath the leader layer.
Formatted: Strikethrough
● If the leader layers layer-number is other than 1, replace the (1) in the expression.
● Tip: If you delete the delay value number and pickwhip “value” of an expression Formatted: Indent: Hanging: 0.25", Outline numbered
slider effect (for example a slider in the leader layer) you can easily change the delay + Level: 1 + Numbering Style: Bullet + Aligned at:
0.75" + Indent at: 0.5"
of all follower-layers at the same time.
Formatted: Strikethrough
delay = 0.5; Formatted: Strikethrough
leader = thisComp.layer(1); Formatted: Strikethrough
leader.transform.position.valueAtTime(time - delay*(index-leader.index)); Formatted: Strikethrough
Formatted: Strikethrough
This expression can be applied to any property, just change the word “position” to “scale”,
“opacity”, or any desired property. Formatted: Strikethrough

ADD: How to make this work with wiggle on the same layer? wiggle and this Formatted: Strikethrough
cancel each other out.
Exponential Scale Formatted: Strikethrough
s=Math.exp(transform.scale[0]/21.667905)-1; Formatted: Strikethrough
[s,s] Formatted: Strikethrough

Countdown Timer Text Formatted: Strikethrough


Counts down from “clockStart” seconds amount to zero in Minute:Second Formatted: Strikethrough
format, then stops(0:00). Starts countdown from beginning of layer, not comp.
Formatted: Strikethrough
COPY the following to the “Source Text” expression box:
Formatted: Strikethrough

rate = -1; Formatted: Strikethrough

clockStart = 300; Formatted: Strikethrough


Formatted: Strikethrough
function padZero(n){ Formatted: Strikethrough
if (n < 10) return "0" + n else return "" + n Formatted: Strikethrough
} Formatted: Strikethrough
clockTime = Math.max(clockStart + rate*(time - inPoint),0);
Formatted: Strikethrough
t = Math.floor(clockTime);
Formatted: Strikethrough
min = Math.floor((t%3600)/60);
Formatted: Strikethrough
sec = Math.floor(t%60);
min + ":" + padZero(sec) Formatted: Strikethrough

Delay inherited parent position Formatted: Strikethrough

Take any parented layer, apply this to position, and it will follow the parent, Formatted: Strikethrough
but on a delay. Formatted: Strikethrough
Formatted: Strikethrough
delay = 0.2; Formatted: Space Before: 14 pt, After: 4 pt, Line
parent.fromWorld(toWorld([0,0,0],time-delay)); spacing: Multiple 1.15 li
Formatted: Strikethrough
Formatted: Strikethrough
This is a collection of useful expression presets I’ve either written, copied or Formatted: Space Before: 0 pt, After: 0 pt, Line
modified from elsewhere on the Internet. If you have one to share, please let spacing: Multiple 1.15 li
me know! Formatted: Strikethrough
Formatted: Strikethrough
Delay inherited parent position
Formatted: Strikethrough
This one has lots of applications, like in this tutorial here. Take any parented Formatted: Space After: 0 pt, Line spacing: Multiple
layer, apply this to position, and it will follow the parent, but on a delay. 1.15 li
delay = 0.2; Formatted: Strikethrough
parent.fromWorld(toWorld([0,0,0],time-delay)); Formatted: Space Before: 14 pt, After: 4 pt, Line
spacing: Multiple 1.15 li
Autofade Formatted: Strikethrough
This fades in and out based on the in point and out point of the layer. Place in Formatted: Space Before: 0 pt, After: 0 pt, Line
spacing: Multiple 1.15 li
the layer opacity.
dur = 0.2; Formatted: Strikethrough
fadeIn = ease(time, inPoint, inPoint + dur, 0, value); Formatted: Space After: 0 pt, Line spacing: Multiple
fadeOut = ease(time, outPoint -dur, outPoint, value, 0); 1.15 li
Math.min(fadeIn, fadeOut);

Fade away from camera Formatted: Strikethrough

Surprisingly, many light plugins like Lux, Optical Flares and Knoll Light Formatted: Space Before: 14 pt, After: 4 pt, Line
spacing: Multiple 1.15 li
Factory lack a way to diminish the light as it points away from the camera.
This can result in really tedious keyframing, unless you have a really Formatted: Strikethrough

awesome expression. Formatted: Space Before: 0 pt, After: 0 pt, Line


spacing: Multiple 1.15 li
v = -toWorldVec([0,0,1]);
Formatted: Strikethrough
i = v[2] * value;
Math.max(i,0); Formatted: Space After: 0 pt, Line spacing: Multiple
1.15 li

Invisible away from camera Formatted: Strikethrough

After Effects cannot really do a sided object, at least not easily. But, you can Formatted: Space Before: 14 pt, After: 4 pt, Line
spacing: Multiple 1.15 li
have its opacity turn off the visibility when it is facing away from the camera.
This way you can even use two objects alternating, creating a fake 2-sided Formatted: Strikethrough

object. Formatted: Space Before: 0 pt, After: 0 pt, Line


spacing: Multiple 1.15 li
try{
Formatted: Strikethrough
a = toWorldVec([0,0,1]);
b = thisComp.activeCamera.position - toWorld(position); Formatted: Space After: 0 pt, Line spacing: Multiple
1.15 li
c = dot(a,b)/length(b);
if (c < 0) value else 0
}
catch(err){value}

Use marker to trigger on for 1 Frame Formatted: Strikethrough

try{ Formatted: Space Before: 14 pt, After: 4 pt, Line


spacing: Multiple 1.15 li
dur = thisComp.frameDuration;
timeToMarker = Math.abs(time - marker.nearestKey(time).time); Formatted: Strikethrough

linear(timeToMarker, dur, 0, 100, 0) Formatted: Space After: 0 pt, Line spacing: Multiple
1.15 li
}catch(err){
100 //or whatevs
} Formatted: Strikethrough
Formatted: Space Before: 14 pt, After: 4 pt, Line
Fade Up and Down to/from marker spacing: Multiple 1.15 li
Formatted: Strikethrough
try{
Formatted: Space After: 0 pt, Line spacing: Multiple
dur = 10 * thisComp.frameDuration;
1.15 li
marker_time = Math.abs(time - marker.nearestKey(time).time);
linear(marker_time, dur, 0, value,0)
}catch(err){
Formatted: Strikethrough
value
Formatted: Space Before: 14 pt, After: 4 pt, Line
}
spacing: Multiple 1.15 li
Formatted: Strikethrough
This is a collection of useful expression presets I’ve either written, copied or
Formatted: Strikethrough
modified from elsewhere on the Internet. If you have one to share, please let
me know! Formatted: Space Before: 0 pt, After: 0 pt, Line
spacing: Multiple 1.15 li

Delay inherited parent position Formatted: Strikethrough


Formatted: Strikethrough
This one has lots of applications, like in this tutorial here. Take any parented
Formatted: Strikethrough
layer, apply this to position, and it will follow the parent, but on a delay.
delay = 0.2; Formatted: Space After: 0 pt, Line spacing: Multiple
1.15 li
parent.fromWorld(toWorld([0,0,0],time-delay));
Formatted: Strikethrough

Autofade Formatted: Space Before: 14 pt, After: 4 pt, Line


spacing: Multiple 1.15 li
Great for slideshows or times when you have lots of layers. This fades in and
Formatted: Strikethrough
out based on the in point and out point of the layer. Place in the layer opacity.
Formatted: Space Before: 0 pt, After: 0 pt, Line
dur = 0.2; spacing: Multiple 1.15 li
fadeIn = ease(time, inPoint, inPoint + dur, 0, value); Formatted: Strikethrough
fadeOut = ease(time, outPoint -dur, outPoint, value, 0);
Formatted: Space After: 0 pt, Line spacing: Multiple
Math.min(fadeIn, fadeOut); 1.15 li
Formatted: Strikethrough
Fade away from camera
Formatted: Space Before: 14 pt, After: 4 pt, Line
Surprisingly, many light plugins like Lux, Optical Flares and Knoll Light spacing: Multiple 1.15 li
Factory lack a way to diminish the light as it points away from the camera. Formatted: Strikethrough
This can result in really tedious keyframing, unless you have a really Formatted: Space Before: 0 pt, After: 0 pt, Line
awesome expression. spacing: Multiple 1.15 li
v = -toWorldVec([0,0,1]); Formatted: Strikethrough
i = v[2] * value; Formatted: Space After: 0 pt, Line spacing: Multiple
Math.max(i,0); 1.15 li
Formatted: Strikethrough
Formatted: Space Before: 14 pt, After: 4 pt, Line
Invisible away from camera spacing: Multiple 1.15 li

After Effects cannot re ally do a sided object, at least not easily. But, you can Formatted: Strikethrough

have its opacity turn off the visibility when it is facing away from the camera. Formatted: Space Before: 0 pt, After: 0 pt, Line
spacing: Multiple 1.15 li
This way you can even use two objects alternating, creating a fake 2-sided
object. Formatted: Strikethrough

try{ Formatted: Space After: 0 pt, Line spacing: Multiple


1.15 li
a = toWorldVec([0,0,1]);
b = thisComp.activeCamera.position - toWorld(position);
c = dot(a,b)/length(b);
if (c < 0) value else 0
}
catch(err){value}

Use marker to trigger on for 1 Frame Formatted: Strikethrough

try{ Formatted: Space Before: 14 pt, After: 4 pt, Line


spacing: Multiple 1.15 li
dur = thisComp.frameDuration;
timeToMarker = Math.abs(time - marker.nearestKey(time).time); Formatted: Strikethrough

linear(timeToMarker, dur, 0, 100, 0) Formatted: Space After: 0 pt, Line spacing: Multiple
1.15 li
}catch(err){
100 //or whatevs
}

Fade Up and Down to/from marker Formatted: Strikethrough

try{ Formatted: Space Before: 14 pt, After: 4 pt, Line


spacing: Multiple 1.15 li
dur = 10 * thisComp.frameDuration;
marker_time = Math.abs(time - marker.nearestKey(time).time); Formatted: Strikethrough

linear(marker_time, dur, 0, value,0) Formatted: Space After: 0 pt, Line spacing: Multiple
1.15 li
}catch(err){
value
} Formatted: Strikethrough
Formatted: Space Before: 14 pt, After: 4 pt, Line
3D Angle between two points spacing: Multiple 1.15 li
a=thisComp.layer("Null 1").position; Formatted: Strikethrough
b=thisComp.layer("Null 2").position; Formatted: Space After: 0 pt, Line spacing: Multiple
diff = sub(a,b); 1.15 li

lookAt(a,b); Formatted: Strikethrough


Formatted: Space Before: 14 pt, After: 4 pt, Line
Average position between two points spacing: Multiple 1.15 li

a=thisComp.layer("Null 1").position; Formatted: Strikethrough

b=thisComp.layer("Null 2").position; Formatted: Space After: 0 pt, Line spacing: Multiple


1.15 li
(a+b)/2;
Formatted: Strikethrough

2D Angle Between Points Formatted: Space Before: 14 pt, After: 4 pt, Line
spacing: Multiple 1.15 li
a = thisComp.layer("Null 1").toComp([0,0,0]);
Formatted: Strikethrough
b = thisComp.layer("Null 2").toComp([0,0,0]);
Formatted: Space After: 0 pt, Line spacing: Multiple
diff = sub(a,b); 1.15 li
radiansToDegrees(Math.atan2(diff[1],diff[0]));

Auto 2D orient Formatted: Strikethrough

L = thisComp.layer("Emitter 2"); Formatted: Space Before: 14 pt, After: 4 pt, Line


spacing: Multiple 1.15 li
p0 = L.toWorld([0,0,0], time-thisComp.frameDuration);
p1 = L.toWorld([0,0,0]); Formatted: Strikethrough

v = p1 - p0; Formatted: Space After: 0 pt, Line spacing: Multiple


1.15 li
radiansToDegrees(Math.atan2(v[1],v[0]));

Polar Coordinates Formatted: Strikethrough

angle = 30; Formatted: Space Before: 14 pt, After: 4 pt, Line


spacing: Multiple 1.15 li
length = 500;
aRad =degreesToRadians( angle - 90); Formatted: Strikethrough

x=radius*Math.cos(aRad); Formatted: Space After: 0 pt, Line spacing: Multiple


1.15 li
y=radius*Math.sin(aRad);
add(position, [x, y]);

Variable Quint Interpolation between a/b Formatted: Strikethrough

dur = 2; //duration in seconds Formatted: Space Before: 14 pt, After: 4 pt, Line
spacing: Multiple 1.15 li
a = 0; //start value
b = 500; //end value Formatted: Strikethrough

tension = 5; Formatted: Space After: 0 pt, Line spacing: Multiple


1.15 li
tensionAdjust =(Math.ceil(tension/ 2) * 2)-1;
function quint(t, b, c, d) {
if ((t/=d/2) < 1) return c/2*Math.pow(t, tensionAdjust) + b;
return c/2*((t-=2)*Math.pow(t, tensionAdjust -1) + 2) + b;
}
t = quint(time - inPoint, 0, 100, dur);
value + linear(t, 0, 100, a, b);

Formatted: Space Before: 14 pt, After: 4 pt, Line


spacing: Multiple 1.15 li
Count with commas Formatted: Strikethrough

startCount = 0; Formatted: Strikethrough


endCount = 10000000; Formatted: Space After: 0 pt, Line spacing: Multiple
duration = 5; 1.15 li
n = ease(time, 0, duration, 0, 10000000);
s = "" + Math.round(n);
s.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
Add 0 to number value using slider control (ex: 01) Formatted: Strikethrough
val = effect("Slider Control")("Slider"); Formatted: Strikethrough
numDec = 0; // digits to right of decimal Formatted: Strikethrough
numDigit = 2; // digits to left of decimal Formatted: Strikethrough
if (val < 0) sign = "-" else sign = ""; s = Math.abs(val).toFixed(numDec); while Formatted: Strikethrough
(s.length < numDigit + numDec + 1) s = "0" + s; sign + s

Infinite Scaling Formatted: Strikethrough


// Throw (scale at a constant speed without keyframes) Formatted: Strikethrough
veloc = 1; //horizontal velocity (pixels per second) Formatted: Strikethrough
x = scale[0] + (time - inPoint) *veloc; Formatted: Strikethrough
y = scale[0] + (time - inPoint) *veloc;
Formatted: Strikethrough

Quick layer stacking. If you’re duplicating a bunch of 3D layers and moving Formatted: Strikethrough
them all back 1 pixel on the Z axis, put this expression on your second layer,
and each time you duplicate it the new layer will be pushed back one pixel:

thisComp.layer(index+1).position + [0,0,1] Formatted: Strikethrough

Hey guys, do you know how to change both x and y scale of a layer when it is Formatted: Strikethrough
parented to another layer? >> A parenting to B (in scale)
So : scale A= scale B-10 Formatted: Strikethrough
Use Layer Marker Comment to drive Type Layer Formatted: Strikethrough

m = thisLayer; Formatted: Strikethrough


n=0; Formatted: Strikethrough

if (m.marker.numKeys > 0){ Formatted: Strikethrough


n = m.marker.nearestKey(time).index; Formatted: Strikethrough
if (m.marker.key(n).time > time) n--; Formatted: Strikethrough
} Formatted: Strikethrough
if (n > 0) m.marker.key(n).comment
Formatted: Strikethrough

Intertial bounce Formatted: Strikethrough


amp= .4; Formatted: Strikethrough
if (m.marker.key(n).time > time) n--; Formatted: Strikethrough
} Formatted: Strikethrough
if (n > 0) m.marker.key(n).comment
Formatted: Strikethrough
Intertial bounce Formatted: Strikethrough
amp= .4; Formatted: Strikethrough
freq=2.0; Formatted: Strikethrough
decay=2.0; Formatted: Strikethrough
n= 0;
Formatted: Strikethrough
Iif (numKeys> 0){
Formatted: Strikethrough

Random blink: Formatted: Strikethrough


r = random(); Formatted: Strikethrough
if (r < 0.5) 0 else 100;

Set Opacity with last two numbers of Comp Name Formatted: Strikethrough
Doesn't work with 100 Formatted: Strikethrough

cName=thisComp.name; Formatted: Strikethrough


cNum=cName.substr(-2,3); Formatted: Strikethrough

[parseInt(cNum)] Formatted: Strikethrough

You might also like