Skip to main content
Participant
Feb 15, 2024 8:40 PM UTC
Question

Using "seedRandom" and "holdTime" to generate position values

I'm using `seedRandom` to produce random position coordinates on a layer. I'm also using `holdTime` to only change position once every second. Is there a way to keep this function but also seed the randomization so that when applying the expression to other layers I can get the same random values?

I don't think I can have them parented to the same null object or just in the same pre-comp because I need to apply different layer styles and masks to different layers but I'd still like for some of them to have the same randomized positions.

Below is the current expression I'm using.

`var holdTime = 1;

seed = Math.floor(time/holdTime);
seedRandom(seed,true);
x = gaussRandom(0,1920);
y = gaussRandom(0,1080);

[x,y]`

 

This topic is closed to new replies. Start a new post to keep the conversation going.

1 reply

Inspiring
Feb 16, 2024 4:16 PM UTC

You can choose a random seed by hard coding a value, but instead of the hold time code, you can simply add 

`posterizeTime(1)` to the top to update the expression once a second. This allows you to set the frame rate for a given property as opposed to a layer or the entire composition. https://ae-expressions.docsforadobe.dev/global.html?highlight=posterizetime#posterizetime-updatespersecond

Translate