Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Crating a carousel using a linear expression and the modulo operator

  • Crating a carousel using a linear expression and the modulo operator

    Posted by David Cabestany on April 6, 2016 at 4:03 pm

    I’m building a carousel, but I have no camera, instead each object is arranged to face the camera when the parent null rotates 60 degrees, so the first object is visible at 60, the second at 120, etc

    Basically I’m in need for a linear expression but I don’t know how to change the third value so it updates for each layer, I thought I could achieve that adding the modulo operator on the 1st value of the expression, but that didn’t work.

    Anyone knows what should I write instead of 60?

    Thanks in advance.
    D.

    r=thisComp.layer("rot").transform.yRotation%60;

    linear(r,0,60,0,100);

    David Cabestany replied 10 years, 5 months ago 2 Members · 5 Replies
  • 5 Replies
  • David Cabestany

    April 7, 2016 at 1:09 am

    No one?

  • Dan Ebberts

    April 7, 2016 at 1:34 am

    Sorry, I’d like to help, but I don’t understand what you’re doing.

    Dan

  • David Cabestany

    April 7, 2016 at 3:22 am

    Thanks Dan. Let me try to explain it better.

    I’m building a simple carousel using a 3D null rotating on the y axis. I’m doing this using keyframes, as the pausing time is not exact for each stop, but rather a bit longer on a few of the stops. Naturally several objects are parented to the null, each object is positioned so it faces the front (I have no camera on the composition) when the null stops at 60,120,180, etc degrees. I want each of the objects to fade in as the null rotates from the last position into the new one, then stays there for a a few frames and moves into the next one, with the object fading out and the new one fading in during this movement which will add another 60 degrees to the rotation cycle the null is following.

    I thought of using a linear expression and have the opacity mapped from 0-60 degrees to 0-100% opacity, that worked great for the first rotation, but then I couldn’t find a way to have the opacity go down from 100 to 0% when the null rotated to its next stop which would be 60 to 120 degrees. So I have a vague idea that maybe the modulo operator could help me achieve this using a conditional statement that somehow enables the opacity on each layer to go from 0 to 100 as the rotation goes from 0 to 60 on the first object, 60 to 120 on the second, 120 to 180 on third and so on.

    Please let me know if this is clear enough. As of now I solved it using keyframes for the opacity but that is not the most productive option since I will be revising the pause duration of each object and then I have to realign all the opacity keyframes with the rotation keyframes in the null.

    Thanks again,
    D.

  • Dan Ebberts

    April 7, 2016 at 4:43 am

    Try this:

    v = toWorldVec([0,0,1]);
    a = Math.abs(radiansToDegrees(Math.atan2(v[0],v[2])))
    linear(a,0,30,100,0)

    Dan

  • David Cabestany

    April 7, 2016 at 3:01 pm

    You are a genius. Thanks a lot, as always.
    Never used any of this functions before, I have lots of reading. ahead of me.

    Best,
    D.

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