Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Help writing script to rotate layer on Y-Axis

  • Help writing script to rotate layer on Y-Axis

    Posted by James Huenergardt on October 20, 2023 at 12:09 pm

    My background is a database programmer turned animator and now I’m delving into Expressions in After Effects. Been doing some scripting in Houdini.

    Things work differently in these timeline based applications scripting wise. I’m assuming the script is executed on every frame. That being said, I’m having difficulty trying to accomplish a rotate task.

    I have a 3D layer where I want to rotate the layer on the Y-Axis, but then while it’s rotating, I want to ‘spin’ it 360 degrees every x-number of seconds.

    I have it slowly rotating from let’s say -35 to 35 degrees over 30 seconds. But let’s say every 3 seconds during that 30 seconds, I want to start where it is currently, spin it 360 degrees, and then continue with the slower rotation.

    I know how to use linear() and ease() but not sure how to logically accomplish this not fully understanding how to set it up.

    Thanks,

    Jim

    Dan Ebberts
    replied 1 year, 1 month ago
    2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    October 20, 2023 at 4:17 pm

    Something like this maybe:

    spinInt = 3; // spin interval
    spinDur = .25; // spin duration
    y = linear(time,0,30,-35,35);
    t = time%spinInt;
    spin = ease(t,spinInt-spinDur,spinInt,0,360);
    y + spin
  • James Huenergardt

    October 20, 2023 at 9:11 pm

    Dan, you’re a genius!

    Now I’m trying to figure out the ‘how’ as far the script works.

    I get the linear() part and even what’s going on with the modulo.

    But the ease() is confusing me a bit. How does it end up returning a 0 until the interval?

    Thanks again!

    Jim

  • Dan Ebberts

    October 20, 2023 at 9:44 pm

    All of the interpolators return the min value (0 in this case) before the interval and the max value (360) after the interval. But since the ease() interval happens at the end of each 3-second interval, there is no “after”, only “before” and “during”. Make sense?

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