Random

random(minValue,maxValue)

random(20,100)

The random expression is very similar to the wiggle expression, but rather than animate between the randomly assigned values like wiggle does, the random expression picks a random value and changes every single frame.

You would have noticed that the expression has two values. The first is the minimum value. Here you enter the lowest value you want the property to achieve. For example, if we put 50 as the minimum value for opacity then the random opacity value generated will never be lower than 50.

The second number is the maximum value. This is the same as the minimum value but is instead the highest value you want to generate.

For example if you used the expression random(50,80); then you will receive values between 50 and 80.

In the example above, the random expression has been added to the opacity of each of the dots. As you can see, the opacity of each dot randomly changes value every frame.

Applying to Scale

The above expression can only be applied to properties with a single value e.g opacity. For the expression to work on a property with two values then the expression is as below:

r = random(10,100);

[r,r]

This will return a random number where both values are equal, meaning it works perfectly for scale.

Applying to Position

The expression used for scale will also work for position, however the x position and y position will always be equal to one-another. If we wanted both our x and y positions to be independent then the expression we need to use is:

x = random(10,100);

y = random(10,100);

[x,y]

This will return a different random number for both the x position and y position, keeping them independent from each-other.

Seed Random

seedRandom(seed,timeless true/false);

seedRandom(1,false);

Looking for more control over the random expression? This addition gives you just that!

The basic random expression, gives you a random value every time you play back the animation or video. This can be annoying if you find a sequence or set of values you like, only for them to randomly change again each time you preview or render. This is because each time we receive a different randomly generated value.

To create consistently random values we need to include the seedRandom line.

The first number within the brackets is the seed. This is the number assigned to any particular random algorithm sequence. If you change this number the sequence will change.

This additional line will not work alone and will need to be placed above our original random expression, as shown below:

seedRandom(1,false);

random(20,100)

Change this seed number to get a different random algorithm sequence.

True vs False

So what is the false statement after our seed number? This is also a great piece of control given to us!

This refers to whether or not the random value is timeless or not. If you leave the timeless statement as false, the expression will generate a random value every frame. If you change it to true, meaning the statement is timeless, then the value will stay the same on every frame.

seedRandom(20,true);

random(20,100)

This is a great way to create a random pattern without any animation.

The example above used the expression on both the position and scale of the dots. The expression is using the layer indexes as the seed numbers so once I have applied it to one layer all I need to do is duplicate that layer as many times as I like to create randomly sized and position dots.

To use the expression using the layer index as it’s seed, the expression will look like this:
seedRandom(index,true);

random(20,100)

Previous
Previous

Loop

Next
Next

Inertia