İçeriğe geç

AFTER EFFECTS EXPRESSIONS

TIme remap speed control

//sp layer: connect your slider effect

tr=0; // the start-value for time-remapping if not 0

t=0;
fd=thisComp.frameDuration;

while(time>t && time>=inPoint) {
sp=thisComp.layer("Control").effect("Speed Control")("Slider").valueAtTime(t)/5;
tr+=sp*fd;
t+=fd;
}

tr-inPoint;

MINIMUM & MAXIMUM VALUE

clamp(Math.round(value), min = 0, max = 100);

LOOPs

loopOut("cycle")
loopOut("pingpong")
loopOut("offset")
loopOut("continue")

Ex: loopOut("pingpong",1)

WIGGLE LOOP

freq = 1;
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)

Camera Focus Target

// Create "Dofx Point" shape layer (Guide Layer)
// Focus Distance Expression from Camera

target = thisComp.layer("Dofx Point")
v1 = target.toWorld(target.anchorPoint) - toWorld([0,0,0]);
v2 = toWorldVec([0,0,1]);
dot(v1,v2)


IF & ELSE

S=thisComp.layer("Processor").effect("Both Channels")("ADBE Slider Control-0001")
W=100

if (S>=30) {W}
else value

OR
if (thisComp.layer("Processor").effect("Both Channels")("ADBE Slider Control-0001") == 1) 100 else 0

Z posıtıon Wıthout scale down (wıth camera)

//Scale expression
cam = thisComp.activeCamera;
distance = length(sub(position, cam.position));
scale * distance / cam.zoom;

one AXIS control

// Only Y AXIS
x = thisComp.layer("Null 1").effect("Slider Control")("Slider"),
[value[1],x]

or
// Only X AXIS
x = thisComp.layer("Null 1").effect("Slider Control")("Slider"),
[x,value[1]]

3D EACH AXIS CONTROL

//Position or 3D point

x= effect("En")("Slider");
y= effect("Boy")("Slider");
z= effect("Derinlik")("Slider");


[x,y,z]

2D EACH AXIS CONTROL

//Position or Scale

x= effect("En")("Slider");
y= effect("Boy")("Slider");

[x,y]

+1 posıtıon each layer

// Position Expression
// Z Axis
[transform.position[0],transform.position[1],transform.position[2]+index+1]
// Y Axis
offset = 150;
[position[0]+offset*index,position[1]];

Auto-OrIent Y Only

//layer's y rotation property

delta = toWorld(anchorPoint) - thisComp.activeCamera.toWorld([0,0,0]);
radiansToDegrees(Math.atan2(delta[0],delta[2]))

Look At Camera

//Orientation Expression

C = thisComp.activeCamera;

V = C.toWorldVec([0,0,1]);
P = toWorld(anchorPoint);
lookAt(P, P + V);

Bend IT

// Start & End Expression

toComp(value)

or add Grow Bounds effect before Bend It.

Transform Center

// Transform Anchorpoint

sizeX = thisLayer.width;
sizeY = thisLayer.height;
[sizeX, sizeY]/2

BOUNCE

// Position expressions

e = .7; //elasticity
g = 5000; //gravity
nMax = 9; //number of bounces allowed
n = 0;

if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0){
t = time - key(n).time;
v = -velocityAtTime(key(n).time - .001)*e;
vl = length(v);
if (value instanceof Array){
  vu = (vl > 0) ? normalize(v) : [0,0,0];
}else{
  vu = (v < 0) ? -1 : 1;
}
tCur = 0;
segDur = 2*vl/g;
tNext = segDur;
nb = 1; // number of bounces
while (tNext < t && nb <= nMax){
  vl *= e;
  segDur *= e;
  tCur = tNext;
  tNext += segDur;
  nb++
}
if(nb <= nMax){
  delta = t - tCur;
  value +  vu*delta*(vl - g*delta/2);
}else{
  value
}
}else

value

CC PARTICLE WORLD CONNECT NULL

// Particle Position Connect Null 1

target = thisComp.layer("Null 1");
(target.position[0]-(thisComp.width/2))/thisComp.width

target = thisComp.layer("Null 1");
(target.position[1]-(thisComp.height/2))/thisComp.width

target = thisComp.layer("Null 1");
target.position[2]/thisComp.width