| Bounce y pos at each marker
• | | | |
 | Bounce y pos at each marker
by Andres Torres on Sep 16, 2012 at 6:37:39 pm |
I'm simply trying to write an expression to bounce y position at each marker. My current code produces unnatural results where the position immediately jumps at each marker.
Thanks.
n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time){
n--;
}
}
if (n == 0){
value;
} else {
freq = 1.0; //oscillations per second
amplitude = 90;
decay = .5;
t = time - marker.key(n).time;
posCos = Math.abs(Math.cos(freq*t*2*Math.PI));
y = amplitude*posCos/Math.exp(decay*t);
position - [0,y]
}
| | | | |
• | | | |  | Re: Bounce y pos at each marker by Dan Ebberts on Sep 16, 2012 at 7:34:54 pm |
Just change Math.cos to Math.sin
(Edit) Actually, I'd also change posCos to posSin, just so the variable name would match what it's used for.
Dan
| | | | |
• | | | |  | Re: Bounce y pos at each marker by Andres Torres on Sep 16, 2012 at 8:22:31 pm |
Thanks Dan, you're amazing.
| | | | |
| |
|