Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions rotation/revolution and opacity

  • rotation/revolution and opacity

    Posted by Michael Mendelsohn on April 23, 2013 at 1:07 pm

    Hi list…

    I’m trying to create a relationship between a null’s rotation and some opacity elsewhere. I read some of Dan Ebbert’s responses, but I can’t seem to get mine to take revolutions into account.

    Here’s what I have, but when I come back around one full revolution, it doesn’t work.

    I’d appreciate any hints. This should be simple, I think.

    – Michael M.

    var a = 0;
    var revs = parseInt((thisComp.layer("master null").transform.yRotation/360)%360);
    var offset = (revs == 0)?0:360;
    var r = Math.abs(offset - thisComp.layer("master null").transform.yRotation)%360;
    var d = Math.abs(a-r);
    ease(d, 10,36, 100,0);

    Michael Mendelsohn replied 13 years ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    April 23, 2013 at 4:22 pm

    What’s the relationship you’re trying to create? I’m sure it’s in there somewhere, but it might be simple if you spell it out.

    Dan

  • Michael Mendelsohn

    April 23, 2013 at 5:31 pm

    Hi Dan, thanks very much for responding. I really appreciate it.

    I have a master null and 4 “satellite” nulls parented to the master, initially set to 0, 90, 180 and 270 degrees respectively. Each of these 4 nulls have a few layers parented to them. These layers’ opacity is tied to its parent null. All 5 nulls are at the same position.

    I’ve rotated the master null with keyframes, which rotates the satellite nulls and their children (like a baby’s mobile). The whole apparatus is like a cube.

    The relationship I’m trying to make is that there should be a range where each face of the cube is 100% opacity when facing the camera, fading in as it approaches an angle (var a), and fades out as it moves away from that angle. My code works, but only for the first revolution, then it breaks. I have a text layer outputting my variable values. I’m just not sure how to tweak the code to make it work after the first 360 degrees.

    My code on the opacity property on each of the satellite nulls, with added comments:

    // on each satellite null's opacity. Children layers' opacity is pickwhipped to this value.
    // this null's parent is "master null"
    // a is either 0, 90, 180 or 270
    var a = 180;
    var r = (thisComp.layer("master null").transform.yRotation)%360;
    var d = Math.abs(a-r);
    ease(d, 10,36, 100,0);

  • Dan Ebberts

    April 23, 2013 at 6:23 pm

    I just tried your expression and it works fine (handles multiple revolutions) for positive rotation values, but to get it to work for negative rotation I had to change the second line to this:

    var r = Math.abs((thisComp.layer(“master null”).transform.yRotation)%360);

    Dan

  • Michael Mendelsohn

    April 24, 2013 at 2:42 pm

    Thanks, Dan! I really appreciate hearing from you!

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