FORUMS: list search recent posts

Random rotation of multiples of 90°, every second

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Simon Francois
Random rotation of multiples of 90°, every second
on Nov 11, 2015 at 10:05:07 pm

Hi all,
I'm learning expression slowly and recently learned using basically seedRandom and ease expression, which I though of applying here, but for some reason, I'm not getting to what I'm aiming.

So, my set up is as follows:
I have 4 items that I want to rotate every second of a -360°, -270°, -180°- -90°, 0, 90°, 180°, 270° or 360° spin.

The script I originally used was to make the 4 last spins, but even there, I'm not getting something proper. Every second it should spin of a multiple of 90°, and take half of a second to get there. Here is my script:

segDur = 1;

seed = Math.floor(time/segDur);
segStart = seed*segDur;
seedRandom(seed,true);
startVal = random(0-4)*90;
seedRandom(seed+1,true);
endVal = random(0-4)*90;
ease(time,segStart,segStart + (segDur/2), startVal, endVal);

It does spin but of various amount of degrees between 0 and 360° whereas I would like to restrict it to only multiples of 90°.

Can anyone tell me where I have wrong?

Thanks a lot in advance


Return to posts index

Dan Ebberts
Re: Random rotation of multiples of 90°, every second
on Nov 11, 2015 at 10:32:40 pm

Try it this way:

segDur = 1;
seed = Math.floor(time/segDur);
segStart = seed*segDur;
seedRandom(seed,true);
startVal = Math.floor(random(4))*90;
seedRandom(seed+1,true);
endVal = Math.floor(random(4))*90;
ease(time,segStart,segStart + (segDur/2), startVal, endVal);


Dan



Return to posts index

Simon Francois
Re: Random rotation of multiples of 90°, every second
on Nov 11, 2015 at 11:26:53 pm

Thanks Dan, it's perfect, as usual!

What was wrong in my script? Was it missing the Math.floor?


Return to posts index


Dan Ebberts
Re: Random rotation of multiples of 90°, every second
on Nov 11, 2015 at 11:30:59 pm

Yes, and I wasn't quite sure what you were doing with the (0-4) in your random calls.

Dan



Return to posts index

Simon Francois
Re: Random rotation of multiples of 90°, every second
on Nov 11, 2015 at 11:34:06 pm

Ha that's right, I always mistake (0-4) for (O, 4).

Thanks a lot! Greetings,
Simon


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]