Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Simple Rotation Controls Opacity Expression?

  • Simple Rotation Controls Opacity Expression?

    Posted by Nick Guth on March 13, 2009 at 12:11 pm
    wheel = comp("Screen").layer("PARENT").transform.rotation; //this is the layer for rotation//
    
    if(304 < wheel < 18) {value=100}
    
    else{value=0};

    I really don’t know much coding, but I have a request for you experts.

    I am trying to have the rotation of a layer control the opacity of another layer, but only between certain values.

    Example:

    I want (layer) to be 100% opacity between the values of 304 and 20 (in rotation value of layer 2). Everywhere else, the opacity = 0.

    This is what I have but it doesnt work at all lol. Please help!!

    Filip Vandueren replied 17 years, 2 months ago 3 Members · 3 Replies
  • 3 Replies
  • Eric Sanderson

    March 13, 2009 at 3:00 pm

    try this out

    wheel = thisComp.layer(“rotation layer”).transform.rotation;

    if(wheel>20&&wheel<304){
    100
    }else{
    0
    }

  • Nick Guth

    March 13, 2009 at 3:06 pm

    Thank you so much. I haven’t slept for like 2 days working on this haha.. I totally forgot about the && and || for if/else expressions!

    Much Obliged.

    Any chance you or someone might know how to make any rotation that goes past 360 NOT wrap around – for sack of that expression not working for any value 1x + 00 for rotation.

  • Filip Vandueren

    March 13, 2009 at 4:32 pm

    if you want to constrain between 0 and 360, try:


    wheel = thisComp.layer("rotation layer").transform.rotation;
    wheel=clamp(wheel,0,360);

    If you want true wrapping around (365° => 5° and -5° => 355°)


    wheel = thisComp.layer("rotation layer").transform.rotation;

    if (wheel >0) {
    wheel=wheel%360;
    } else {
    wheel = 360 + (wheel%-360);
    }

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