ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Randomise Position based on layer marker

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
rosie skinner
Randomise Position based on layer marker
on Apr 12, 2018 at 3:00:01 pm

Hi everyone!

I have this script for randomising the position on a layer

random([thisComp.width,thisComp.height])

but I'd really like the position to change at a layer marker... anyone got any ideas?

Thanks!


Return to posts index

Dan Ebberts
Re: Randomise Position based on layer marker
on Apr 12, 2018 at 4:02:14 pm

Try this:


m = marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (m.key(n).time > time) n--;
}
seedRandom(n,true);
random([thisComp.width,thisComp.height])



Dan



Return to posts index

rosie skinner
Re: Randomise Position based on layer marker
on Apr 12, 2018 at 4:08:38 pm

Genius! Thank you!!

If you have a bit of time would you mind explaining it?

No worries if not!


Return to posts index


Dan Ebberts
Re: Randomise Position based on layer marker
on Apr 13, 2018 at 12:34:46 am

It looks for the most recent, previous marker and uses that marker's index as the random seed (it uses zero, if there is no previous marker).

Dan



Return to posts index

rosie skinner
Re: Randomise Position based on layer marker
on Apr 13, 2018 at 9:18:33 am

Great thanks so much!


Return to posts index

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