Hello There !
I’m back with half a problem.
After editing the code you kindly provided. I wanted to do the same thing but by combining the :” Inertial Bounce ” script you wrote.
It kinda works. except the movement do not go gradually from 0 to 300, but instead it jumps right to it.
I understand the problem is not having the ” .duration” of the marker being referenced in the expression.
A weird thing also appeared and I completely not understand why, the first marker is triggering a bounce but… no movement. As it should move from 0 to 300 on the marker duration and so on when hitting the next one.
Here a gif
https://ibb.co/5sRSt3F
Thanks you any help provided.
moveAmt = 300
if (m.numKeys > 0) {
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
accum = 0;
y = 0;
if (n > 0){
if ( n > 1){
for (i = 1; i < n; i++){
if (m.key(i).comment == "Spin") accum += moveAmt
}
}
if (m.key(n).comment == "Spin"){
t = time - m.key(n).time - 1;
y = velocityAtTime(m.key(n).time) ;
amp = .05;
freq = 4.0;
decay = 8.0;
}
val = y + amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t) + accum;
}
val
}