Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Falloff scale but maintain distance?

  • Falloff scale but maintain distance?

    Posted by Simon Smith on August 20, 2023 at 8:21 pm


    am trying to emulate the attached without using tons of keyframes. I want to (ideally) parent a bunch of layers to a null and as the null animates across screen, want each layer to scale up and down as it passes through the centre of screen.

    Have tried using Motion’s falloff function (as well as manual expressions and another couple of scripts) – the automatic scaling’s fine but always run into the same problem – as the central layer scales, the distance between it and its neighbours (logically) reduces whereas I need it to maintain a constant distance. Tried proximity script to a central null but obviously the layer being scaled passes through that and it all goes wrong.

    I think my questions are, anyone done something like this before, and logically, am I asking the impossible?


    Brie Clayton replied 9 months, 2 weeks ago 3 Members · 5 Replies
  • 5 Replies
  • Filip Vandueren

    August 29, 2023 at 10:04 am

    It’s pretty hard to do in expressions, because every layer’s position and scale is depending on all others:

    If a layer scales up because it is close to the center, it pushes the other layers some pixels to the left and right, where it they also would have a different distance from the center, so they need to adjust their scale, which again needs to move all layers before/after them.

    The order in which this needs to happen is not easy to determine.

    I think if there’s a workable solution, it would need to be simulated and calculated inside of a text-layer, and then all the layers getr thier position and scale from that text-layer’s output. Havinf every indivicual layer calculate its own position and scale isn’t possible.

  • Filip Vandueren

    August 29, 2023 at 11:09 am

    Here is an example using the precalculations in the text-layers:

    parentLayer=thisComp.layer("Null 1");
    firstLayer=thisComp.layer("Null 1").index+1;
    margin = 40;
    bulge = 133;
    falloffMin = 0;
    falloffMax = 600;
    data = [];
    for (i=firstLayer; i<=lastLayer; i++) {
    w = thisComp.layer(i).sourceRectAtTime().width;
    if (i>firstLayer ) {
    w_1 = thisComp.layer(i-1).sourceRectAtTime().width;
    x+=margin + (w + w_1)/2;
    d = Math.abs(parentLayer.toComp([x,0])[0] - 960); // d = x-distance to center of comp
    s = ease(d, falloffMin, falloffMax, bulge, 100);
    extraW = w*(s-100)/200; // how many pixels wider did the scale make the shape (divided by 2)
    data.forEach( e => e.x-=extraW ); // each previous shape deducts extraW, moving left
    data.push({x:x, s:s});
    x+=extraW; // the running total x gets an additional extraW, shifting each following shape right
  • Simon Smith

    September 2, 2023 at 4:23 pm

    That’s fantastic! Thanks so much!

  • Simon Smith

    September 3, 2023 at 7:48 pm

    Sorry, know I’ve already said thanks but the more I play with this and the more I find how flexible it is, the more in awe I am. 😄 Genius. Absolutely what I needed. Thank you! !

  • Brie Clayton

    September 4, 2023 at 2:02 pm

    Thank you for the solve, Filip!

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