Auto-Orient Along Path

try{
cornerEase = 3;
p = transform.position;
t = Math.min(Math.max(time,p.key(1).time+.001),p.key(p.numKeys).time);
pre = position.valueAtTime(t-thisComp.frameDuration*cornerEase);
post = position.valueAtTime(t+thisComp.frameDuration*cornerEase);
delta = post-pre;
orient = radiansToDegrees(Math.atan2(delta[0],-delta[1]));
value+orient+180
}catch(err){
value
}

Animation from marker

keyStart и keyStartN - this start animation keys.  keyEnd - key from which the animation ends.

try{
if(marker.numKeys>1&&numKeys>1){
beginAnim=marker.key(1).time;
endAnim=marker.key(2).time;
markerMoveTime=endAnim-beginAnim;

// Start animation keys
keyStart=key(1).time;
keyStartN=key(2).time;

// End animation keys
keyEnd=key(3).time;
if(time>=beginAnim && time<=endAnim)
{if((time-beginAnim)>=(keyStartN-keyStart)){valueAtTime(keyStartN);}
else valueAtTime(keyStart+(time-beginAnim));
}
else if(time>endAnim)
{valueAtTime(keyEnd+(time-endAnim));}
else if(time<beginAnim) {valueAtTime(keyStart);}
else {value;}
}else value;
}catch(err){value;}

startValue endValue

duration = 1; // Duration of animation in seconds
startVal = 0; // Start value
endVal = 100; // End value
endTime = inPoint+duration;
Math.round(linear(time,inPoint,endTime,startVal,endVal))

Look At

Target = thisComp.layer("Target");
delta = thisLayer.toComp([0,0]) - Target.toComp([0,0]);
radiansToDegrees(Math.atan2(delta[1],delta[0]))+180

Limit the distance between two layers

With this expression, you can limit the distance between two layers, so that the distance does not exceed the specified value. Applies to the Position parameter.

For 2D-layers:

centre=thisComp.layer("Centre");
radius = 512; // Maximum distance
x0=value[0]-centre.transform.position[0];
y0=value[1]-centre.transform.position[1];
distance0 = Math.sqrt(x0*x0+y0*y0);
distance = Math.min(distance0,radius);
if (distance0>radius){
distance_mult = distance/distance0;
}else{
distance_mult = 1
}
x=centre.transform.position[0]+distance_mult*x0;
y=centre.transform.position[1]+distance_mult*y0;
[x,y]

For 3D-layers

centre=thisComp.layer("Orbit");
radius = 505;
x0=value[0]-centre.transform.position[0];
y0=value[1]-centre.transform.position[1];
z0=value[2]-centre.transform.position[2];
distance0 = Math.sqrt(x0*x0+y0*y0+z0*z0);
distance = Math.min(distance0,radius);
if (distance0>radius){
distance_mult = distance/distance0;
}else{
distance_mult = 1
}
x=centre.transform.position[0]+distance_mult*x0;
y=centre.transform.position[1]+distance_mult*y0;
z=centre.transform.position[2]+distance_mult*z0;
[x,y,z]

Start typing and press Enter to search