Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Change value when position reaches certain value

  • Change value when position reaches certain value

    Posted by Shashank Raghu on October 27, 2020 at 1:59 pm

    Hi,

    I want Text layer Opacity to change its value from 100 to 50 when the shape layer reaches the position x & y value between 90 and 110.

    x = transform.position[0];
    y = transform.position[1];
    a = thisComp.layer("Shape Layer 1").transform.position[0];
    b = thisComp.layer("Shape Layer 1").transform.position[1];
    z = x + y;
    c = a + b;
    if(z == c){
    50;
    } else {
    100;
    }

    // Comp Size = 200, 200
    // x and y value = [100, 100]
    // a and b value = [100, 100]

    in this, the opacity is exactly changing when Shape Layer reaches [100, 100],
    but I want opacity to change when the shape layer position value is between [90,90] and [110, 110]

    And if the Text Layer position is [50, 50] opacity should change from 100 to 50 when the Shape Layer position value reaches + or – 10(between [40, 40] and [60, 60]) to the Text Layer position value.

    Shashank Raghu replied 5 years, 6 months ago 2 Members · 2 Replies
  • 2 Replies
  • Brendon Murphy

    October 28, 2020 at 4:42 am

    try this:

    x = transform.position[0];

    y = transform.position[1];

    a = thisComp.layer("Shape Layer 1").transform.position[0];

    b = thisComp.layer("Shape Layer 1").transform.position[1];

    firstMin = 40;

    firstMax = 60;

    secondMin = 90;

    secondMax = 110;

    //this sets opacity rules for when text pos is [50,50]

    if (x==50 && y==50 && a>firstMin && b> firstMin && a<firstMax && b< firstMax ){

    50

    }else{

    //if text pos is not [50,50], set the opacity based on the other shape values

    if(a>secondMin && b>secondMin && a<secondMax && b<secondMax ){

    50

    } else {

    100

    };

    };

  • Shashank Raghu

    October 28, 2020 at 10:50 am

    It worked thanks a lot.

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