Creative Communities of the World Forums

The peer to peer support community for media production professionals.

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

  • Expression to push and scale object in different directions?

    Posted by Shane Brown on March 7, 2024 at 11:00 pm

    Hello, I’m looking for some advice on a method to replicate the attached gif. Basically I want to know how can I have one object affect the position and scale of a neighboring object.

    Shane Brown replied 2 years, 2 months ago 3 Members · 5 Replies
  • 5 Replies
  • Yoan Boisjoli

    March 8, 2024 at 3:17 am

    I can’t see the gif in action from my phone (only a thumbnail) but it seems like something similar to what the script “Flex” offers. Here’s the link:

    http://aescripts.com/flex/

    If not, let us know and we can figure it out!

  • Tom Morton

    March 8, 2024 at 11:10 am

    position and scale properties for all objects are natively changeable via expressions, what have you tried so far?

  • Tom Morton

    March 8, 2024 at 11:13 am

    Had to download to view, wouldn’t be mega complicated to do this using expressions if you’re familiar with them. If you’re not, I suggest watching some tutorials or doing a course on them first maybe, this will help you find the best way of doing it.

  • Shane Brown

    March 11, 2024 at 3:38 am

    Thank you very much for this recommendation – I’m going to look into this!

  • Shane Brown

    March 11, 2024 at 3:43 am

    Hi Tom, I’m very new to expressions so I’m still trying to learn what I can about them while actively practicing. I actually got pretty close by using GPT to help.

    I set the anchor point of the pink shape to the bottom right corner and the grey shape to the top left corner and then added expressions to the position properties of each shape.

    For the pink shape I added this expression:

    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];

    And for the grey, this one:

    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];

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