
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
09/11/2025
Dalet today announced a transformative leap forward for media operations: Agentic Artificial Intelligence (AI) that unifies the Dalet ecosystem under one natura...
05/11/2025
A 13-year old company that serves as a master control/disaster recovery hub for PBS stations says it has seen little financial impact from cuts to public broadc...
05/11/2025
To no one's surprise, the NFL's most dominant franchise in recent years attracts the most TV viewers, according to new research by S&P Global Markete In...
05/11/2025
MELBOURNE, Australia Atomos today introduced Ninja TX GO, a new HDMI monitor-recorder that combines a brighter screen, advanced monitoring tools, professional c...
05/11/2025
WASHINGTON Despite the ongoing government shutdown, Federal Communications Commission Chairman Brendan Carr has announced a tentative agenda for the agency'...
05/11/2025
The College Football Playoff (CFP), ESPN and TNT Sports have announced kick times and broadcast information for the 2025 CFP First Round, which will launch the ...
05/11/2025
NEW YORK IAB Tech Lab, the global digital advertising technical standards-setting body, has announced the release of device attestation support in the industry ...
05/11/2025
SINGAPORE Appear, an Oslo-based provider of live production technology, is opening a new facility in Singapore as part of the company's expansion into the A...
05/11/2025
DALLAS Parks Associates has released new data showing just how far the dramatic shift to streaming services has gone in recent years. Currently, more than nine ...
05/11/2025
New schedule will be live on-air Monday 10 November
Brand-new Today with David McCullagh from 9am
Oliver Callan in all-new extended show from 11am to 1pm
Kie...
05/11/2025
Explore the future with Science Week on RT
Dive into a week of innovative, themed programming and content across RT television, radio and online
Includes a ...
05/11/2025
Get ready for six weeks of United FC, a brand-new, feel-good teen docuseries kic...
04/11/2025
SVG Sit-Down: Why Professional Fight League CEO John Martin Believes Growth Is I...
04/11/2025
SVG All-Stars: David Koppett, Executive Producer, Live Sports and Studio, NESN a...
04/11/2025
From concept to kick-off: How TAMS could transform sports workflows By Paul Markham
Tuesday, October 28, 2025 - 09:43
Print This Story
Techex tx darwin pr...
04/11/2025
College Hoops Preview 2025: The CW Tips Off Third Season of ACC Men's/Women&...
04/11/2025
College Hoops Preview 2025: Big Ten Network Heats Up for Busy Season With 500 Me...
04/11/2025
College Hoops Preview 2025: CBS Sports Readies 300+ Game Broadcasts Across Its P...
04/11/2025
College Hoops Preview 2025: NBC Sports Slate Features 200+ Big Ten, BIG EAST, an...
04/11/2025
College Hoops Preview 2025: ESPN Remote-Ops Team Preps for Massive Slate of 7,40...
04/11/2025
Never-before-seen footage of Selena Quintanilla and her family's band offers...
04/11/2025
Joel Edgerton at Train Dreams Park City premiere (photo by Soul Brother / Shutterstock for Sundance Film Festival)...
04/11/2025
Today, we announced our third quarter 2025 earnings, marking strong momentum as we surpassed 700 million Monthly Active Users and achieved double-digit subscrib...
04/11/2025
Idag rapporterar vi v rt resultat f r det tredje kvartalet 2025, vilket markerar en stark och fortsatt tillv xt d vi passerade 700 miljoner m natliga aktiva an...
04/11/2025
SBS calls for bold, thought-provoking factual ideas: up to $50,000 in developmen...
04/11/2025
Tomorrow's fight will demand networks that deliver both capacity and survivability, the speed to move mission applications at scale, and the resilience to e...
04/11/2025
New York, NY - November 3, 2025 - Neptune BidCo US Inc. (the Issuer or the Co...
04/11/2025
WASHINGTON The National Association of Broadcasters took aim at YouTube TV and its owner Google in a blog post for its heavy hand in deciding what viewers can ...
04/11/2025
HACKENSACK, N.J. The European Broadcasting Union (EBU) has awarded LiveU a five-year contract to deliver 24/7 live news content through its Eurovision News Exch...
04/11/2025
Bob Dylan Awarded Honorary Doctorate from Berklee College of Music The songwriter, performer, and cultural icon is recognized for a six-decade career that redef...
04/11/2025
SAN JOSE, Calif. Roku has launched Roku Ads API, a fully open, self-serve developer platform for connected TV (CTV) advertising. The Roku Ads API gives develope...
04/11/2025
Harmonic (NASDAQ: HLIT) today announced an expanded partnership with Spectrum to extend the company's industry-leading cOS vCMTS and advanced network and o...
04/11/2025
The inauguration of Empresa de Meios Audiovisuais' (EMAV's) first virtual studio in Lisbon marks a major technological milestone for the Portuguese audi...
04/11/2025
ZTransform, a leader in transformational system design, integration, and launch services for broadcasters, sports venues, educational facilities, and corporate ...
04/11/2025
Fred Baumgartner's op-ed (ATSC 3.0: I Cant Imagine Anyone Defending Our Current Adoption Strategy) on the broadcast industry's transition to ATSC 3.0 dr...
04/11/2025
Q&A with Music Alum Andrew van der Paardt The oboist and English horn player reports back from the pit of the New York City Ballet Orchestra, and tells how he...
04/11/2025
Damien Moloney as Jim Bergerac
As filming wraps on the highly anticipated second series of Bergerac(6x60'), UKTV today unveils a selection of first look im...
04/11/2025
Tuesday 4 November 2025
To view this content, please enable our use of cookies....
04/11/2025
Back to All News
Netflix and Embratur launch audiovisual tourism guide at the W...
04/11/2025
Back to All News
Frankenstein' Sightings Grip Hollywood With Halloween Wee...
04/11/2025
From the recent SMPTE Media Technology Summit in Pasadena, with FilmLight Image Engineer, Daniele Siragusano, and Research Engineer, Julius Tschannerl.
Matchin...
04/11/2025
Begins Thursday November 6 on RT One and RT Player at 10:15pm
Camogie: Inside...
04/11/2025
In Berlin on Tuesday, Deutsche Telekom and NVIDIA unveiled the world's first...
04/11/2025
When inspiration strikes, nothing kills momentum faster than a slow tool or a frozen timeline. Creative apps should feel fast and fluid - an extension of imagin...
04/11/2025
Douglas W. Phillips and Steven M. Paul join Scripps Research Board of Directors Finance and biomedical leaders bring decades of experience in investment strateg...
03/11/2025
SVG Sit-Down: Inside the Sports Rights Landscape (and the new IMG) with Andrew D...
03/11/2025
Challenging the norm: How TNT Sports is evolving coverage of the men's and w...
03/11/2025
Inspired storytelling: TNT Sports' Pete Thomas on creating opportunities out...
03/11/2025
NBA 2K League Returns With New Format Featuring NBA Players, Creators, and FansSeason will include online tournaments, in-person events, and open-ladder fan com...
03/11/2025
Live on the Water: The Rowing Channel Pulls Off Historic Production at Head Of T...