Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › How can you combine an if else expression with a linear expression?

  • How can you combine an if else expression with a linear expression?

    Posted by Bea Hammond on June 25, 2025 at 4:40 pm

    Hi, I am trying to link the opacity of one layer to the rotation of a parent null “MASTER”. I want it to be visible from the front, fade as it turns, and not be visible from behind. So, for instance, the opacity should be 100% when the rotation is between -50 and 50 and fade out when it rotates up to 63 degrees either way, and be 0 if the rotation is more than 63 degrees either way.

     

    Can anybody help? I came up with this but it doesn’t seem to be working:

    Thanks!

     

    var yRot = thisComp.layer(“MASTER”).transform.yRotation;

    if (yRot<-63||yRot>63)0

    if (yRot>=50&&yRot<=63)

    linear(yRot,50,63,100,0)

    if (yRot<=-50&&yRot>=-63)

    linear(yRot,-50,-63,100,0)

    else 100

    Dan Ebberts replied 1 year, 3 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    June 25, 2025 at 5:12 pm

    Try it this way:

    var yRot = thisComp.layer("MASTER").transform.yRotation;
    if (yRot< -63 || yRot > 63)
    0
    else if (yRot >= 50 && yRot <= 63)
    linear(yRot,50,63,100,0)
    else if (yRot <= -50 && yRot >= -63)
    linear(yRot,-63,-50,0,100)
    else
    100

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