-
Expression to return last value when Checkbox is enabled
Hi everybody,
So I’m trying to combine solutions from Dan Ebberts and it’s not working so far.
I have the falling leaf effect that Dan wrote here:
https://www.aenhancers.com/viewtopic.php?t=8
And I’m trying to combine it with his code to return the last expression value at time here:
https://forums.creativecow.net/thread/227/34463
It’s not really working, and I don’t know how to fix it. The code I’ve attached is on position.
Any ideas?
yVelocity = 200; //pixels per second
oscFreq = thisComp.layer("Null 1")("Effects")("Oscillation Frequency")("Slider"); //oscillations per second
oscDepth = 35; //oscillation depth (pixels)
drift = 25; // drift (wind?) (pixels per second: - = left, + = right)
chkBx = thisComp.layer("Null 1")("Effects")("Stop")("Checkbox");
n = 0;if (chkBx.numKeys > 0){
n = chkBx.nearestKey(time).index;
if (chkBx.key(n).time > time) n--;
}
t = 0;
curTime = time;
if (n > 0){
for (i = n; i > 0; i--){
if (chkBx.key(i).value > 0){
t += (curTime - chkBx.key(i).time);
}
curTime = chkBx.key(i).time;
}
if ((curTime > 0) && (chkBx.key(1).value > 0)) t += curTime;
}else{value + [oscDepth*Math.sin(oscFreq*Math.PI*2*time) + drift *time,
yVelocity*time,0]
}