Forums › Adobe After Effects Expressions › Opacity jumps to a higher starting point than defined in the linear() expression
-
Opacity jumps to a higher starting point than defined in the linear() expression
-
Hauke Sterner
March 6, 2023 at 4:20 pmHello all!
I’m fairly new to expressions and I have a problem with the following:
L is a static circle that just fades in.
M is the same circle, but it moves across the composition (only x-position).
L is supposed to fade in once M hits the x-position of L.This is my expression:
L = thisComp.layer(“Punkt”);
M = thisComp.layer(“Punkt_Maske”);if (M.transform.position[0] >= L.transform.position[0]) {
L.transform.opacity = linear(time, 0, 33);
} else {
0;
}This expression kind of works, but the opacity of L does not start at 0 like stated in linear(), but jumps to a higher percentage and continues to 33%.
Can somebody tell me what I’m doing wrong?
Thanks! 🙂
-
Dan Ebberts
March 6, 2023 at 4:54 pmYour expression needs to calculate how long ago the trigger event happened. Also, you didn’t mention how long the fade in should take, so I just set it to .5 seconds:
L = thisComp.layer("Punkt");
M = thisComp.layer("Punkt_Maske");
fadeDur = .5;
if (M.transform.position[0] >= L.transform.position[0]) {
t = time - thisComp.frameDuration;
while (M.transform.position.valueAtTime(t)[0] >= L.transform.position[0]){
t -= thisComp.frameDuration;
}
linear(time-t,0,fadeDur,0,33);
} else {
0;
}
Log in to reply.