Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression Request or Fix: Turning layer’s opacity based on other layers location.

  • Expression Request or Fix: Turning layer’s opacity based on other layers location.

    Posted by Gerald mark Soto on November 26, 2012 at 4:46 pm

    Essentially I want a layer”s opacity to be at 100% but when it reaches a certain position it turns off. I want it to turn off when it meets another layer’s position exactly. It would also need to work if the layers are parented to other layers or nulls. So it would probably need a toWorld position location or toComp.
    check the images. I think its a “if else” expression. i tried this:

    pos= thisComp.layer(“BloackB”).transform.position;

    if (position == pos){
    100
    }else{
    0
    }

    images:
    https://tinyurl.com/d58v5s3

    https://tinyurl.com/c68zzal

    Gerald mark Soto replied 13 years, 5 months ago 2 Members · 3 Replies
  • 3 Replies
  • Jean-françois Robichaud

    November 26, 2012 at 8:35 pm

    Position uses sub-pixel values, so doing an equality comparison isn’t going to work very well. You could use a tolerance, depending on how close you want to be. For a tolerance of 2 pixels, try this:

    p1 = thisComp.layer(“BloackB”).transform.position;
    p2 = position;
    tolerance = 2;
    if (length(p1, p2) < 2) 100
    else 0

    As for layers that are parented to nulls or other layers, I can never work it out of the top of my head, so I’ll let others work it out.

  • Gerald mark Soto

    November 26, 2012 at 9:13 pm

    (Sorry I just realized what your last sentence was about parenting.)

    Great, But….
    Works Perfect, Actually.

    The But,
    How can this work if the Block A & Block B are parented to different Nulls. In this case, this is why i mentioned the toComp, toWorld Position recognition. I just tried and it dosent work anymore once they are parented. Hmmmm.

    Image reference:
    https://tinyurl.com/cwd7w8l

    https://tinyurl.com/a5w

    Thanks again.

  • Gerald mark Soto

    November 26, 2012 at 9:24 pm

    Thanks So Much. With your help I was able to figure out hot to make it work off any position when parented using the toComp that I already kinda know. Here it is. It must be messy but it works for what i need it.

    L1 = thisComp.layer(“BlockA”);
    LCP1 = L1.toComp([0,0,0]);
    L2 = thisComp.layer(“BlockB”);
    LCP2 = L2.toComp([0,0,0]);
    p1 = LCP1;
    p2 = LCP2;
    tolerance = 1;
    if (length(p1, p2) < 2) 0
    else 100

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