Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Scale Layers by Proximity to a hero layer & stay scaled!

  • Peter Menich

    April 19, 2012 at 12:19 pm

    I’ve managed to hack Colins position expression and apply it to the scale parameter, but its pretty ugly.

    Anyone got a more elegant solution?

    avoidPos = thisComp.layer("ActionNull").position;
    maxDisplacement = 100; //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;
          finalPos += displacementVec
          } catch ( exception ){
             finalPos;
          }
    }
    x=finalPos-transform.position;

    if(x[0]>=100){
    x=[100, 100]
    }else{
    x=[x[0], x[0]]
    }

  • Peter Menich

    April 19, 2012 at 2:49 pm

    I think I’ve found a more elegant solution here…

    https://forums.creativecow.net/thread/227/16128#16128

    happy days!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy