-
rotating a clock based on time
Hi,
I’m trying to write a (simple I thought) code for rotating a clock, based on the actual time in the comp.
I figured it would work like this.1) Have something constantly counting (variable i), in my example using timeToFrames
2) Translate that to seconds, I used Math.floor(i/25) to get the current second (yeah the base is 25)
3) see if the variable is equal to the variabel seconds.
4) if so, rotate the pointer with 6 degrees.This didn’t quite work, I think because the condition only occurs on one frame.
So I tried adding another counter, c. That would be set to 6 when i and seconds matched up.
Then, as long as c was less or equal to 6 i would subtract it by 1 and rotate the layer by 1 degree.Sadly this didn’t work either. Anyone has any thoughts on how to solve this?
rot = this.rotation;
i = timeToFrames(t = time + thisComp.displayStartTime, fps = 1.0 / thisComp.frameDuration, isDuration = false);
seconds = Math.floor(i/25);
if (i/25 == seconds) {
c = 6;
} else {
c = 0; }if (c <= 6) {Â
c = -1;
transform.rotation = rot+1;
}