
Generating Random Motion Using AE 5.5's Expressions
Dan Ebberts July 26, 2023
0 Comments
Originally published in 2002
In this tutorial, Dan Ebberts demonstrates a method of generating motion that is random in both time and space and allows you to quickly assemble a composition with a pleasantly fluid, chaotic movement.
Download Movie
Project File: .sit (currently unavailable)
The Problem:
The concept behind this tutorial came out of an online discussion. A fellow After Effects enthusiast was trying to come up with an expression to generate motion that was random in time and space. That is, target positions would be random as would the time it takes to get there. The problem that you encounter when trying to develop such an expression is that there just doesn't seem to be a good way to carry the value of variables forward in time from one frame to the next. Any variables that you define will be gone at the next frame. Consider the following example expression for opacity:
if (time = 0){
x = 10
}
else{
x = x 1
}
This works fine at the first frame. At the second frame you get an error because x is undefined. The expression doesn't remember that x was 10 on the previous frame. This becomes a serious limitation when you are trying to do something over a random amount of time because once you decide how long it should take, you need to check at every frame to see if you're done yet. Hard to do if you can't pass that value from one frame to the next.
Seed_random To The Rescue:
It turns out that you can get around this problem with the enhanced (for AE 5.5) seed_random function. This function allows you to establish a repeatable sequence of random numbers and regenerate them at will, just by restoring the seed to a previous value and then calling the random() function. This gives us a solution to the problem because even though we can't pass our random values from one frame to the next, we can recreate them using seed_random. Let's look at how seed_random works.
Open the project file and then open the basic comp . This is just a 640 480 comp with a 50 50 solid layer added. Select Solid 1 and reveal the position property. Alt-click (Option-click) on the stopwatch to activate the expression for this property. Enter the following expression:
[random(0,this_comp.width),random(0,this_comp.height)];
This will cause the square to jump to a random position in the comp. Preview the comp. You'll notice that the square jumps to a new position on every frame. Not very useful. Add a new line to the expression so that it now reads:
seed_random(1,true);
[random(0,this_comp.width),random(0,this_comp.height)];
Notice that again the square jumps to a random position but when you preview it stays there. This new behavior is due to a change that Adobe made to the seed_random function for AE 5.5. They've added a second parameter, that when set to true sets the random function so that random numbers generated don't depend on time. The random numbers depend on the layer number, the property number, the value of the first parameter in the seed_random call (the seed ), and the number of times the random function has been called. That means that the same expression will generate different random numbers in a different layer or property (later we will take advantage of this to quickly add complexity to our comp). Try changing the seed parameter to some other number. You'll notice that the square moves to a different location and stays there. Change the second parameter to false and notice that when you preview, the square jumps all over the place again.
Add a little more code to your expression so that it looks like this:
if (time < 1){
seed_random(1,true)
}
else{
seed_random(2,true)
}
[random(0,this_comp.width),random(0,this_comp.height)];
Now you'll notice that when you preview, the square stays at one location for the first second and then jumps to another location for the remainder of the comp.
So how do we use this new, more powerful seed_random function? Here's the key concept: With the second parameter set to true , for a given layer, property, and seed value, the random number you get when calling the random() function only depends on how many times you have called the function since setting the seed. That is, the first time you call random() after setting the seed you will get a particlar random number (let's call it x). The second call will generate a second random number (let's call this one y) and so on. But if you call seed_random again with the original seed, the sequence will start over. That is, the next random() call will regenerate the original random number (x in this case). Using a different seed value will cause a completely different sequence to be generated. Consider the following example:
seed_random(1,true); //set the seed value
A=random();
B=random();
C=random();
seed_random(1,true); //reset the seed to the same value
I=random();
J=random();
K=random();
seed_random(2,true) //new seed
Q=random();
R=random();
S=random();
seed_random(1,true); // reestablish original seed
X=random();
Y=random();
Z=random();
In this case, A,B, and C will all be different random numbers. However, A and I will be the same, B and J will be the same, and C and K will be the same because the seed has been reset (to 1 in this case) and the random sequence starts over. Q,R and S will be a new sequence of random numbers because the seed has been changed to 2. The sequence X,Y,Z will be the same as A,B,C and I,J,K because the seed has been set to 1 again. So we can return to a sequence of random numbers by reestablishing the seed value that generated those numbers.
How does this help us? To generate our random motion, at any given frame we need to know several things about the current segment of motio
Most recent headlines
05/01/2027
Worlds first 802.15.4ab-UWB chip verified by Calterah and Rohde & Schwarz to be ...
16/11/2026
November 16, 2026
Hitachi system enables proton beams to be delivered from 360 degrees around the patient, expanding treatment capacity and supporting more pre...
16/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
16/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
16/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
16/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
16/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
16/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
16/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
16/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
16/11/2026
Hiltron Communications has received a repeat order from one of Europes longest established communications satellite operators. Central to this project is a Hilt...
16/11/2026
Fabric Insights and Fonn Group today announce a partnership to connect editorial planning and media operations across their complementary product portfolios.
...
16/11/2026
Density 1.0 brings a complete color grading workflow to Final Cut Pro
Brie Clayton November 16, 2026
0 Comments
Filmmaker Pascal Basel's plugin pr...
16/11/2026
Berklee Students to Perform at Boston's CITGO Sign Relighting Kuper Walker, Ollie Mann, and dreamcorp. will perform at the free public celebration in Kenm...
16/11/2026
The Hollywood Reporter Names Berklee Among World's Best Music Schools The annual list spotlights Berklee's screen scoring programs and new master'...
16/11/2026
Five years ago, Lightware launched the original Taurus UCX with a clear vision: USB-C would become the central connection in meeting rooms. The goal was simple:...
16/11/2026
Sonniss: bundles over 80% below their libraries' prices, plus up to 60% off ...
16/11/2026
Singaporean Comedy Luck My Life Shot with Blackmagic URSA Cine 17K 65
Brie Clayton November 16, 2026
0 Comments
Blackmagic PYXIS 12K and DaVinci Resol...
16/11/2026
As countries gather to discuss climate targets at COP 31 this week, one question that is at the heart of debates is how to measure the environmental impact of t...
16/11/2026
Announced today at SC26, NVIDIA Rubin HPC is a new GPU in the NVIDIA Vera Rubin ...
16/11/2026
This week at SC26, NVIDIA is marking two decades of CUDA by honoring the researchers, developers and engineers who helped make GPU computing a foundation for mo...
16/11/2026
With expanded NVIDIA CUDA-X libraries, including cuPhoton, cuPotential and cuSpa, researchers can sift through vast amounts of data to accelerate research, from...
16/11/2026
In its MLPerf benchmarks debut, with results released today, the NVIDIA Vera Rub...
16/11/2026
Quantum processor deployments at supercomputing centers have grown nearly sevenfold over the past five years, with nearly 30 supercomputing centers around the w...
16/11/2026
To train an AI model, thousands of GPUs have to work together, requiring a network that's fast, efficient and resilient.
Lambda is tackling the network pie...
15/11/2026
Mixers, interfaces & DAW controller receive new firmware
Yamaha have just launched a trio of firmware updates that bring some powerful new functionality to ...
15/11/2026
Can VideoProc AI Really Reduce Noise and Enhance Blurry, Old Footage? Real-World...
15/11/2026
Over two days at COEX, more than 2,000 attendees converged for AI Day Seoul, bri...
14/11/2026
Longtime MLB Network employee David Maybrown passed away Thursday at the age of 57. David joined MLB Network in 2009 shortly after its launch, beginning as an i...
14/11/2026
Modular innovators introduce two guitar-based products
ADDAC System's recently introduced Four String Series makes it possible to integrate physical str...
14/11/2026
Marcelo Dai's Live Session Captured with URSA Cine Immersive
Brie Clayton November 14, 2026
0 Comments
Artist takes viewers on an immersive journe...
14/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
14/11/2026
Share
{alert(Link copied)}).catch(err => {console.error(Failed to copy: , err)}) data-platform=copy_link data-action= class=font-ui-heading py-2 text-sm tex...
14/11/2026
Newest Lenses, Horizon Anamorphic Seminar & Guided Lens Character Experience Highlight Creative Possibilities
At the 2026 Toru CAMERIMAGE Film Festival, ZEISS...
14/11/2026
Sonnet Announces Black Friday Sale on Select Products
Brie Clayton November 14, 2026
0 Comments
WHAT: Sonnet Technologies is having a sale on a select...
14/11/2026
Berklee Alumni Shine at the 2026 Latin Grammy Awards This year's winners included songwriters, engineers, and performers who contributed to acclaimed reco...
13/11/2026
The UIM E1 Series wraps its third season this week with the Bombay Sapphire E1 Miami GP, Nov. 11-14, on Biscayne Bay at the Miami Seaplane Base on Watson Island...
13/11/2026
In-venue and creative video staffers at the professional and collegiate level ha...
13/11/2026
Singer-songwriter Benson Boone will headline entertainment for the Discover NHL Winter Classic between the Utah Mammoth and Colorado Avalanche at Rice-Eccles St...
13/11/2026
Blackmagic Design has announced the Blackmagic Ambisonic Microphone, a 7th order ambisonic microphone array that captures spatial audio for immersive video prod...
13/11/2026
SMPTE has announced that The Studio B&H and Riedel Communications will provide the video infrastructure and communications technology for the Solutions Hub at t...
13/11/2026
The Hollywood Professional Association (HPA) has announced the theme and program focus for the 2027 HPA Tech Retreat, which takes place Feb. 14-18, 2027, in La ...
13/11/2026
Football Manager 27 Touch is available on Apple Arcade starting today. The game ...
13/11/2026
MotoGP has announced a two-year media rights agreement with ESPN covering the Un...
13/11/2026
Apple Sports, the free iPhone app, has added the Ultimate Fighting Championship (UFC) to its lineup of supported sports, in time for Saturday's UFC 334. The...
13/11/2026
The NBA and Fanatics Studios, the joint venture between Fanatics and entertainme...
13/11/2026
ESPN held its annual EDGE Innovation Conference last night and offered up an ove...
13/11/2026
Regional sports network gives Ithaca College, SUNY Cortland students a platform to thrive
One of the biggest games in Division III college football will be pla...
13/11/2026
Studer-inspired 500-series PWM compressor unveiled
The HLabs range already includes a couple of Studer-inspired offerings in the form of the PRE169 and EQ16...