ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Random roation at a layer marker

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jonas Millgård
Random roation at a layer marker
on May 5, 2019 at 3:40:46 pm

Hi,

In this post https://forums.creativecow.net/docs/forums/post.php?forumid=227&postid=3464... the rotation is accumulated at the layer marker.

I'm looking for a similar behaviour except that I would like it to rotate a random figure between e.g. -360 to 360.
I've been reading Dan's text about random motion at https://motionscript.com/mastering-expressions/random-1.html, however I can't get my head around how to solve the accumulation when using a random rotation figure. Your input how to tackle it is very much appreciated. In Dan's text a "while" loop is used that goes through the comp one frame at a time and adds up the random numbers, I'm figuring I would need one as well but I'm sure how.

Thanks
Jonas


Return to posts index

Kalleheikki Kannisto
Re: Random roation at a layer marker
on May 6, 2019 at 6:50:05 am

Since you are using markers, you would not need to loop every frame, just every marker. You can use the number of markers that you have passed as the loop end number and the current iteration in the loop as the randomSeed, adding the rotations up inside the loop.

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

Jonas Millgård
Re: Random roation at a layer marker
on May 6, 2019 at 9:42:30 pm

Thanks Kalleheikki for the guidance! It really helped me head in a good direction.

This is what I came up with and it seems to work.

rotateTime = .6;
rotateAmt =0;
minVal = -270;
maxVal = 270;
accum = 0;
j = 1;


n = 0;
if (marker.numKeys > 0){
n = marker.nearestKey(time).index;
if (marker.key(n).time > time)n--;
}
if (n > 0){
t = time - marker.key(n).time;
while (j < n) {
seedRandom(j,true);
accum += random(minVal,maxVal);
j++;
}
seedRandom(j,true);
rotateAmt = random(minVal,maxVal);
r = accum + ease(t,0,rotateTime,0,rotateAmt);
value + r;
}else
value


Return to posts index


Kalleheikki Kannisto
Re: Random roation at a layer marker
on May 8, 2019 at 2:49:19 pm

👍

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

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