Help - Random position expression


#1

Hope someone can give me a tip…

I’ve got this simple expression which does the trick except I need to be able to control the speed, for example, rather than every frame, perhaps every second, fourth, fifth frame…

Or even better, something like ‘change layer position between these X and Y ranges every random number of frames between n1 and n2.’

X=position[0]+random(900,-300); Y=position[1]+random(-100,500); [X,Y]

It’s not really practical in this case to pre-compose the layer and use, say, Posterize Time.

TIA :slight_smile:


#2

hi,

check this out http://www.motionscript.com/mastering-expressions/random-1.html


#3
Generator said

Hope someone can give me a tip…

I’ve got this simple expression which does the trick except I need to be able to control the speed, for example, rather than every frame, perhaps every second, fourth, fifth frame…

Or even better, something like ‘change layer position between these X and Y ranges every random number of frames between n1 and n2.’

X=position[0]+random(900,-300); Y=position[1]+random(-100,500); [X,Y]

It’s not really practical in this case to pre-compose the layer and use, say, Posterize Time.

TIA :slight_smile:

use a seedRandom and then for the seed a function based on the time.

tFrame = timeToFrames(time);

tSeed = Math.floor(tFrame/3);

seedRandom(tSeed,true);

position + [random(-300,900), random(-100, 500)];

//gives a random position every third frame


#4

Brilliant! Thank you felt.