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 7:59 am

    Hello,

    I want Opacity to change the value from 100 to 50 when the Shape Layer position is around [90, 90] and [110, 110]. I wrote this expression on opacity

    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 changing exactly at the value [100, 100] but I wanted to change it when a and b value is within 90 to 110

    Filip Vandueren replied 5 years, 6 months ago 3 Members · 3 Replies
  • 3 Replies
  • Filip Vandueren

    October 27, 2020 at 9:19 am
    // something like this:
    p = thisComp.layer("Shape Layer 1").transform.position;
    if ( (p[0]>=90 && p[0]<=110) || (p[1]>=90 && p[1]<=110) ) {
    o = 50;
    } else {
    o = 100;
    }
    o;
  • Matt Volp

    October 27, 2020 at 9:21 am

    Instead of using

    ==

    you’ll need to use

    >= or <=
  • Filip Vandueren

    October 27, 2020 at 9:22 am

    Alternatively, (if you would look in a circle of radius 10px around [100,100] instead of inside of a box from 90,90 to 110,100):

    p = thisComp.layer("Shape Layer 1").transform.position;
    o = length(p,[100,100]) < 10 ? 50 : 100;

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