Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression to push and scale object in different directions?

  • Graham Quince

    March 8, 2024 at 2:53 pm

    I can’t get any animation in that gif to play, so it is a bit difficult trying to figure out what you’re hoping to achieve, but at a guess, I’d suggest taking a look at the linear expression.

    This lets to map one set of values onto another, something like:

    var newScale = linear(“moving layer’s”.position[0],250,500,100,25]
    [newScale,newScale]

    So you could take the moving layer’s position and as it’s X value (position[0]) moves from 250 to 500, the scale drops from 100 to 25.

  • Nils Hammers

    March 9, 2024 at 5:23 pm

    If I were doing something similar, I’d approach the problem from another direction.
    The main object there is that black grid box that scales from zero to hero, to which the pink and gray boxes are pinned (not parented); the pink box will have the anchorPoint snapped to the bottom right corner, the gray box – to the upper left corner.
    Expression for the pink box’s position might be something like:
    b = thisComp.layer(“BlackBox”) ;
    fromComp(b.toComp([0, 0]) ;

    For the gray box:

    b = thisComp.layer(“BlackBox”) ;
    fromComp(b.toComp([b.width, b.height]) ;

    Now, when the black box scales from 0, the pink and gray boxes appear like pulling the opposite corners of black box.

  • Shane Brown

    March 11, 2024 at 3:48 am

    Hi Nils, this tip helped me out! I ended up actually using GPT to help me figure this out. This was the solution that got me pretty much close to figuring it out. I added these expressions to the positions of the pink and grey boxes

    Pink Shape:

    var blackBox = thisComp.layer(“Black Box”);

    var blackBoxPosition = blackBox.transform.position;

    var blackBoxScale = blackBox.transform.scale[0] / 100;

    var xOffset = (blackBox.width / 2 * blackBoxScale) + (thisLayer.width / 2 * blackBoxScale);

    var yOffset = (blackBox.height / 2 * blackBoxScale) + (thisLayer.height / 2 * blackBoxScale);

    [blackBoxPosition[0] – xOffset, blackBoxPosition[1] – yOffset];

    Grey Shape:

    var blackBox = thisComp.layer(“Black Box”);

    var blackBoxPosition = blackBox.transform.position;

    var blackBoxScale = blackBox.transform.scale[0] / 100;

    var xOffset = (blackBox.width / 2 * blackBoxScale) + (thisLayer.width / 2 * blackBoxScale);

    var yOffset = (blackBox.height / 2 * blackBoxScale) + (thisLayer.height / 2 * blackBoxScale);

    [blackBoxPosition[0] + xOffset, blackBoxPosition[1] + yOffset];

  • Silas Figueroa

    March 31, 2024 at 12:02 am

    You can use a linear scaling expression or a join expression to bind object parameters. This will allow one object to control another depending on certain conditions or movements

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