stevesketch
12/18/2017 - 3:34 AM

#AE_Position

// 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]
avoidPos = thisComp.layer("Avoid Me").position;
maxDisplacement = 200; //maximum amount to move the layer
minDistance = 100; //minimum distance to begin displacing at
//--
finalPos = position.valueAtTime(0);
oldDirectionVec = normalize([1,1]);
for( i = 0 ; i <= time; i+= thisComp.frameDuration ){
   try{
      vec = finalPos - avoidPos.valueAtTime( i );
      directionVec = normalize( vec );
      oldDirectionVec = directionVec;
      distance = length( vec );
      displaceAmt = ease( distance , 0 , minDistance , maxDisplacement , 0 );
      displacementVec = displaceAmt * directionVec;
      finalPos += displacementVec
      } catch ( exception ){
         finalPos += oldDirectionVec * displaceAmt;
      }
}
finalPos;
transition = thisComp.layer("Controls").effect("TransTime")("Slider"); // time in secs
// center X & Y
// used to split comp into quarters
cY = thisComp.height/2;
// make boolean from index 
// odd = true or even = false
change = Boolean( index % 2 ); 
// initialise x, y with placeholders
moveX = value[0];
moveY = value[1]; 
// get current width & height of layer
// factoring in the scale
H = (this.sourceRectAtTime(time).height/2)*(transform.scale[0]*0.01)+1; 
// get midpoint of layer time
midTime = (inPoint+outPoint)/2;
/// EASING FUNTION
function outExpo(t, d, b, c) {
  return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  
}
// EASING mapping to percentage
easeVal = outExpo(time-inPoint, transition, 0,100); // in
if (time > midTime) easeVal = outExpo(outPoint-time-0.1, transition, 0,100); //out
// remap the easing to actual values
if (value[1] <= cY ) {  // left 
moveY  = linear(easeVal, 0, 100,  0-H, value[1]);
}  else if (value[1] > cY) {  // right
moveY = linear(easeVal, 0, 100, thisComp.height + H,value[1]);   // in from right
} // return final values
[moveX ,moveY];
// Automatically slide layer in and out from outside comp
// uses exponetial ease in and out
// and layer index (odd or even) to switch direction
//
// 1. Place layer where you want it to end up
// 2. Paste the below script onto the position
// 3. change the 'transition' variable for timing
//    or link to a slider on a control layer

transition = 1; // time in secs
// center X & Y
// used to split comp into quarters
cX = thisComp.width/2;
// make boolean from index 
// odd = true or even = false
change = Boolean( index % 2 ); 
// initialise x, y with placeholders
moveX = value[0];
moveY = value[1]; 
// get current width & height of layer
// factoring in the scale
W = (this.sourceRectAtTime(time).width/2)*(transform.scale[0]*0.01)+1; 
// get midpoint of layer time
midTime = (inPoint+outPoint)/2;
/// EASING FUNTION
function outExpo(t, d, b, c) {
  return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  
}
// EASING mapping to percentage
easeVal = outExpo(time-inPoint, transition, 0,100); // in
if (time > midTime) easeVal = outExpo(outPoint-time-0.1, transition, 0,100); //out
// remap the easing to actual values
if (value[0] <= cX ) {  // left 
moveX  = linear(easeVal, 0, 100,  0-W, value[0]);
}  else if (value[0] > cX) {  // right
moveX = linear(easeVal, 0, 100, thisComp.width + W,value[0]);   // in from right
} // return final values
[moveX ,moveY];
// Automatically slide layer in and out from outside comp
// uses exponetial ease in and out
// and layer index (odd or even) to switch direction
//
// 1. Place layer where you want it to end up
// 2. Paste the below script onto the position
// 3. change the 'transition' variable for timing
//    or link to a slider on a control layer 

transition = 1; // time in secs

// find center X & Y
// used to split comp into quarters
cX = thisComp.width/2;
cY = thisComp.height/2;

// make boolean from index 
// odd = true or even = false
change = Boolean( index % 2 );
// initialise x, y with placeholders
moveX = value[0];  
moveY = value[1];

// get current width & height of layer
// factoring in the scale
W = (this.sourceRectAtTime(time).width/2)*(transform.scale[0]*0.01)+1; 
H = (this.sourceRectAtTime(time).height/2)*(transform.scale[1]*0.01)+1; 
// get midpoint of layer time
midTime = (inPoint+outPoint)/2;

/// EASING FUNTION
function outExpo(t, d, b, c) {
  return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  }
// EASING mapping to percentage
easeVal = outExpo(time-inPoint, transition, 0,100); // in
if (time > midTime) easeVal = outExpo(outPoint-time-0.1, transition, 0,100); //out

// remap the easing to actual values
if (value[0] <= cX && value[1] <= cY && !change) {  // top left quadrant and  even index
moveY  = linear(easeVal, 0, 100, 0-H,value[1]);   // in from top
} else if (value[0] <= cX && value[1] <= cY && change) {  // top left quadrant and  oddindex
moveX  = linear(easeVal, 0, 100,  0-W, value[0]);
//    easeOut(easeVal , 0, 100 ,0-W,value[0]);   // in from left
}  else if (value[0] > cX && value[1] <= cY && !change) {  // top right quadrant and  even index
moveY  = linear(easeVal, 0, 100, 0-H,value[1]);   // in from top
}  else if (value[0] > cX && value[1] <= cY && change) {  // top right quadrant and  odd index
moveX = linear(easeVal, 0, 100, thisComp.width + W,value[0]);   // in from right
} else if (value[0] <= cX && value[1] > cY && !change) {  // botom left quadrant and  even index
moveY  = linear(easeVal, 0, 100,  thisComp.height+H,value[1]);   // in from bottom
}  else if (value[0] <= cX && value[1] > cY && change) {  // botom left quadrant and  odd index
moveX  = linear(easeVal, 0, 100,  0-W,value[0]);   // in from left
} else if (value[0] >  cX && value[1] > cY && !change) {  // botom right quadrant and  even index
moveY  = linear(easeVal, 0, 100,thisComp.height+H,value[1]);   // in from bottom
}  else if (value[0] >  cX && value[1] > cY && change) {  // botom right quadrant and  odd index
moveX  = linear(easeVal, 0, 100, thisComp.width + W,value[0]);   // in from right
}
// return final values
[moveX ,moveY];
l = thisComp.layer("My3DLayer");
l.toComp(l.anchorPoint);
delta = index%8;
n =thisComp.layer("Null").transform.xPosition;
n_k = n.key(2); //out-1, in-2

null_pos = n.valueAtTime(time-delta*thisComp.frameDuration);  //shift delta frames left

value + null_pos - n_k;
L = thisComp.layer("child layer");
L.toWorld(L.anchorPoint);