ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Gerald SotoExpression Request or Fix: Turning layer's opacity based on other layers location.
by on Nov 26, 2012 at 4:46:41 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:
http://tinyurl.com/d58v5s3

http://tinyurl.com/c68zzal


Return to posts index


Jean-Fran├žois RobichaudRe: Expression Request or Fix: Turning layer's opacity based on other layers location.
by on Nov 26, 2012 at 8:35:02 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.


Return to posts index


Gerald SotoRe: Expression Request or Fix: Turning layer's opacity based on other layers location.
by on Nov 26, 2012 at 9:13:26 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:
http://tinyurl.com/cwd7w8l

http://tinyurl.com/a5w

Thanks again.


Return to posts index


Gerald SotoRe: Expression Request or Fix: Turning layer's opacity based on other layers location.
by on Nov 26, 2012 at 9:24:25 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]