-
Coding to randomly rotate a cube on z axis
I am trying to make the rotation on a cube random, but so that it stops on a face for a random (or fixed) amount of time then randomly spins around and stops on another face.
My coding below makes it rotate randomly, but I have no idea how to make it stop on a face.
segDur = 3;
seed = Math.floor(time/segDur);
segStart = seed*segDur;
seedRandom(seed,true);
startVal = random(360+transform.zRotation);
seedRandom(seed+1,true);
endVal = random(360+transform.zRotation);
linear(time,segStart,segStart + segDur, startVal, endVal);I did try to do an if loop so that a variable is returned from the rotation value at a specific frame, and when that variable is equal to 90, 180 etc, then a posterizeTime expression is done for a random/fixed about of time, but I didn’t get very far, because I have no idea how to!
Is there any chance that someone had tried this sort of thing before and can give me some pointers on the code. I have a little coding experience, but hardly any in JavaScript.
Also, does anyone know of an AE specific JavaScript book that I can get hold of to make scripting a bit easier?
Many thanks,
Victoria