Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Animate compositions with expressions

  • Animate compositions with expressions

    Posted by Yoshiko Tanaka on October 27, 2023 at 12:24 am

    I am a super newbie to expressions. I want to move a long background composition horizontally continuously throughout the animation. Instead of manually move it in two key frames I want to use expressions so that I can add additional comps over it and match the speed easily. Please advise. Thank you so much in advance!

    Yoshiko Tanaka replied 2 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Tom Morton

    October 27, 2023 at 6:37 am

    Hello there, in the position property of the layer you want to animate you can ALT + click on the stopwatch to open the expressions for that property. So in your case, ALT+click on the stopwatch that is on the “position” property for the layer and it should drop down / add a text box with a default expression in (which will do nothing yet)

    Then the expression you probably want is the “linear()” expression. Type in this:

    —script—

    y = 540; // or whatever the default height is, this won’t change

    x = linear(time, 0, 5, 150, 2000); //change the x position over time

    [x, y] // position property is an array of 2 values for x and y position

    —script—

    That should do the trick. The linear expression takes 5 arguments, just off the top of my head but in “linear(time, 0, 5, 0, 2000)”

    1. The first argument is what you’re measuring, in this case “time”

    2. the second argument is when it starts from, in this case 0 seconds

    3. the third one is where it ends, so it will keep animating until 5 seconds

    4. the fourth one is the value it starts ag

    5. the fifth one is the value it finishes at.

    So, from 0-5 seconds, the X position will change from 150 to 2000, if that makes sense! The y position is set at the beginning and is static, but you could also put a linear() expression in here to change the height of the layer over time. And if you want to go extra pro, you can add / subtract multiple linear() expressions over different times to get a range of different movement!!

    Enjoy!

  • Yoshiko Tanaka

    October 27, 2023 at 2:06 pm

    Thank you for the thorough explanation. This seems like something like a newbie like me can handle. Thank you!

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