-
Using a Point Controller instead of 2 separate sliders giving me an error
I have been messing around with Dan Ebbert’s frequency expression to create an oscillating position for objects. I set up the expression so X and Y had independent frequencies. It works great if I pull my ‘freq’ variables from sliders. But in an effort to consolidate controllers, I tried to replace the two X and Y frequency sliders with a Point Controller, thinking I could pull the frequency values from that. But when swap the slider for one of the point values, the expression breaks with a “couldn’t turn result into a numeric value’ error. I can’t figure out why it’s not a number. Here’s the expression:
// Calculate X Frequency
xfreq = effect(“Point Control”)(“Point”)[0];
amp = effect(“X_Amp”)(“Slider”);
n = xfreq.numKeys;
if (n > 0 && xfreq.key(1).time < time){
accum = xfreq.key(1).value*(xfreq.key(1).time – inPoint);
for (i = 2; i <= n; i++){
if (xfreq.key(i).time > time) break;
k1 = xfreq.key(i-1);
k2 = xfreq.key(i);
accum += (k1.value + k2.value)*(k2.time – k1.time)/2;
}
accum += (xfreq.value + xfreq.key(i-1).value)*(time – xfreq.key(i-1).time)/2;
}else{
accum = xfreq.value*(time – inPoint);
}
x = value[0] + amp*Math.sin(accum*Math.PI*2);// Calculate Y Frequency
yfreq = effect(“Point Control”)(“Point”)[1];
amp = effect(“Y_Amp”)(“Slider”);
n = yfreq.numKeys;
if (n > 0 && yfreq.key(1).time < time){
accum = yfreq.key(1).value*(yfreq.key(1).time – inPoint);
for (i = 2; i <= n; i++){
if (yfreq.key(i).time > time) break;
k1 = yfreq.key(i-1);
k2 = yfreq.key(i);
accum += (k1.value + k2.value)*(k2.time – k1.time)/2;
}
accum += (yfreq.value + yfreq.key(i-1).value)*(time – yfreq.key(i-1).time)/2;
}else{
accum = yfreq.value*(time – inPoint);
}
y = value[1] + amp*Math.sin(accum*Math.PI*2);[x,y];