oscillation by frame
Posted: August 12th, 2009, 2:40 pm
I'm trying to write a script that causes a solid to oscillate between two positions with each frame.
What I've come up with works most frames, but skips beats. Entering the script below in a 30 fps comp, the object is static from 0:00:04:02 - 0:00:04:04. What's wrong with my math?
What I've come up with works most frames, but skips beats. Entering the script below in a 30 fps comp, the object is static from 0:00:04:02 - 0:00:04:04. What's wrong with my math?
Code: Select all
var xDisp = 0
var yDisp = 20
var fps = 30
var x = Math.floor(fps*time)
if(x%2==1) transform.position+[xDisp, yDisp] else transform.position-[xDisp, yDisp ]