FORUMS: list search recent posts

Loop Random Velocity

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Luke Regan
Loop Random Velocity
on Apr 10, 2014 at 6:11:53 pm

Hi,

I need to loop an object moving from top to bottom of the screen at random speeds/velocity.

Let me explain further what I mean. I have two keyframes for an object's y value. It starts on the top of the screen and ends at the bottom of the screen. Pretty simple. I then added a loopOut("cycle") expression so the object continually loops, moving from the top of the screen to the bottom, over and over. Perfect...

Now what I need is for the object's velocity or speed to randomly change each time it loops. Basically I want the time it takes the object to reach the bottom of the screen to be different every time it loops.

How can I do this using expressions? Thanks!


Return to posts index

Dan Ebberts
Re: Loop Random Velocity
on Apr 10, 2014 at 6:36:18 pm

This is one way. Adjust minDur and maxDur to get the range of transition times you like:


minDur = .5;
maxDur = 2.5;

if (numKeys > 1){
t = tPrev = inPoint;
seedRandom(index,true);
while (t <= time){
tPrev = t;
t += random(minDur,maxDur);
}
linear(time,tPrev,t,key(1).value,key(2).value);
}else
value



Dan



Return to posts index

Luke Regan
Re: Loop Random Velocity
on Apr 10, 2014 at 9:53:37 pm

Thanks Dan! This works perfectly.

Any chance you could briefly explain how the code snippet works?


Return to posts index

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