Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

Random position (no smooth motion)?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
Filip NordlingRandom position (no smooth motion)?
by on Jul 23, 2012 at 7:17:33 pm

Hi there,

I am trying to make a layer to randomly move position around the screen (even off screen), but with no smooth motion. Basically at one second it should be at x=500 and the other second at x=1250. But it should stay at x=500 until that second has passed to the other. It should be like a blink, and not move to x=1250 during the milliseconds. See what I mean? So no movements, just randomly position itself to another random place on the screen during random seconds.


Thanks in advance,
Filip


Return to posts index
Reply   Like  

Dan EbbertsRe: Random position (no smooth motion)?
by on Jul 23, 2012 at 7:36:58 pm

This should give you a new x position between 500 and 1250 every second:

minX = 500;
maxX = 1250;

seed = Math.floor(time);
seedRandom(seed,true);
x = random(minX,maxX);
[x,value[1],value[2]]


Dan



Return to posts index
Reply   Like  

Filip NordlingRe: Random position (no smooth motion)?
by on Jul 23, 2012 at 7:41:51 pm

Thanks for the quick answer!

In addition, is there a way to also control the amount of time it should take until it swaps to another position? I believe it's just a minor change in your code, but I'm not sure which...


Thanks again!


Return to posts index
Reply   Like  


Dan EbbertsRe: Random position (no smooth motion)?
by on Jul 23, 2012 at 7:59:16 pm

Well, not a minor change, but this should do it:


minX = 500;
maxX = 1250;
minDelay = 1;
maxDelay = 5;

tEnd = 0;
n = 0;
seedRandom(n, true);
while (time >= tEnd){
n++;
seedRandom(n,true);
dur = random(minDelay, maxDelay);
tEnd += dur;
}
x = random(minX,maxX);
[x,value[1]]


Dan



Return to posts index
Reply   Like  

Filip NordlingRe: Random position (no smooth motion)?
by on Jul 23, 2012 at 8:09:26 pm

Awesome, thanks!

Last question. The Y position. I'd like to do the same thing there, but somehow it doesn't do anything to Y if I add another line with the same code as the X ones. How come?


Thanks


Return to posts index
Reply   Like  

Dan EbbertsRe: Random position (no smooth motion)?
by on Jul 23, 2012 at 8:24:42 pm

Like this maybe?



minX = 500;
maxX = 1250;
minY = 0;
maxY = 1000;

minDelay = 1;
maxDelay = 5;

tEnd = 0;
n = 0;
seedRandom(n, true);
while (time >= tEnd){
n++;
seedRandom(n,true);
dur = random(minDelay, maxDelay);
tEnd += dur;
}
random([minX,minY],[maxX,maxY]);



Dan



Return to posts index
Reply   Like  


Filip NordlingRe: Random position (no smooth motion)?
by on Jul 23, 2012 at 8:34:43 pm

Yepp, that's it!

Thanks a ton!


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]