Layer Hits Error When Using Variable in Expression Linked to Slider
I'm using Dan Ebberts' inertial bounce code. If I leave the variables as simple assignments, like below, it works:
amp = .25;
freq = 2.0;
decay = 6.0;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}}
if (n == 0){ t = 0;
}else{
t = time - key(n).time;
}
if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}
However, if I create and link Sliders to modify those variables (so as to do so globally within the file) it catches an error:
amp = thisComp.layer("Bounce Controls").effect("Amp")("Slider");
freq = thisComp.layer("Bounce Controls").effect("Freq")("Slider");
decay = thisComp.layer("Bounce Controls").effect("Decay")("Slider");
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}}
if (n == 0){ t = 0;
}else{
t = time - key(n).time;
}
if (n > 0){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}
The error is:
"Error at line 19 in property 'Scale' of layer 18 ("Title_of_Layer") in comp 'Title_of_Comp'. Invalid numeric result (divide by zero?)., an expression was disabled as a result of an error."
Any insights on why? The variables are (in theory) identical. I'm sure I'm just missing something in the fundamentals. Thanks for any help!
