
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 ...
04/08/2026
Dalet, a leading technology and service provider for media-rich organizations, t...
04/07/2026
April 7 2026, 19:00 (PDT) Detective Conan: Fallen Angel of the Highway Opens in...
01/06/2026
January 6 2026, 05:30 (PST) Dolby Sets the New Standard for Premium Entertainment at CES 2026
Throughout the week, Dolby brings to life the latest innovatio...
20/05/2026
True to the Music City theme, the Tennessee Titans plan to make live music a prominent fixture on game days at the new venue
Reflecting the continuing converge...
20/05/2026
The long-term goal is innovation for the next generation of hockey rinks at both the professional and the community level
The National Hockey League (NHL) toda...
20/05/2026
End-users and vendors alike work toward cost-effective yet high-quality solution...
20/05/2026
The National Football League has announced that Nashville will host Super Bowl LXIV in 2030 at the new Nissan Stadium. The announcement was made at the NFL Spri...
20/05/2026
The NFL has announced that the 2028 NFL Draft presented by Bud Light will take place in Minnesota, uniting fans from around the world to celebrate one of the mo...
20/05/2026
As professional AV workflows continue to evolve, expectations around audio, video, networking, and control are rising rapidly. At InfoComm 2026 in Las Vegas, La...
20/05/2026
Haivision will showcase its latest innovations at InfoComm 2026, taking place fr...
20/05/2026
For the seventh year, Spotify is returning to CMA Fest with Spotify House, the festival's premiere destination for fans. We're taking over downtown Nash...
20/05/2026
Amp-simulation software expanded
Acustica Audio's latest release greatly expands on their amp-simulation platform, turning it into a complete amplifica...
20/05/2026
MainStage integration, Analog Lab improvements & more
Arturia have just announced the release of an update that brings an assortment of new features to thei...
20/05/2026
At the Annual General Meeting held on May 20, 2026, the shareholders of SGL Carb...
20/05/2026
From Gulkula to the nation: Yothu Yindi Foundation and NITV deepen national acce...
20/05/2026
SBS appoints David Fernandez as National Manager, Digital & TV Sales
20 May, 2026
Media releases
SBS has appointed David Fernandez as National Manager, Dig...
20/05/2026
Rohde & Schwarz and INFOZAHYST: A strategic alliance set to redefine modern defe...
20/05/2026
A Rotating Detonation Engine being hot fire tested at Purdue University's Zu...
20/05/2026
A U.S. Army VAMPIRE system, assigned to Bravo Battery, 1st Battalion, 51st Air Defense Artillery Regiment, 7th Infantry Division/Multi-Domain Command - Pacific ...
20/05/2026
Cable Captures Only Monthly Increase Among Viewing Categories in March, Earns it...
20/05/2026
April brought a symbolic decrease in the overall time spent in front of television screens. On average, Poles watched video content for 3 hours and 51 minutes a...
20/05/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/05/2026
The Royal Television Society Technology Centre today announces the launch of the RTS Technology Awards 2026, celebrating excellence, innovation and achievement ...
20/05/2026
In the heart of London's financial district, the new purpose-built Troubadour Canary Wharf Theatre invites audiences to experience Suzanne Collins' inte...
20/05/2026
LiveU, the leader in live IP-video solutions, today announced that production powerhouse BCC Live successfully deployed the new LU900Q intelligent production un...
20/05/2026
Nella Mente di Narciso Docuseries Uses Blackmagic Design Workflow
Brie Clayton May 19, 2026
0 Comments
PYXIS 6K full frame camera and DaVinci Resolve ...
20/05/2026
Beeble launches Canvas, a node-based AI compositor for VFX and Virtual Productio...
20/05/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/05/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/05/2026
Share
Copy link
Facebook
X
Linkedin
Bluesky
Email...
20/05/2026
First Nations Factual Co-production Development Fund launched to elevate Indigen...
20/05/2026
TLC Announces All-Star Comedy Line-Up for Mock the Week: Summer Specials' o...
20/05/2026
Back to All News
One Hundred Years of Solitude Concludes This August, With Part...
20/05/2026
Back to All News
Beloved NHK Dramas to Stream on Netflix Worldwide Starting June 22
Entertainment
20 May 2026
GlobalJapan
Link copied to clipboard
Netflix...
20/05/2026
May 20 2026, 06:00 (PDT) Dolby Recognized as 2025 Supplier of the Year and Over...
20/05/2026
Mayo's Dee Freney and Margaret Leahy from Galway have reached the final of RT Today's TV Home Cook competition.
Both contestants will cook again live...
20/05/2026
RT IN FULL BLOOM AT BORD BIA BLOOM 2026 WITH LIVE BROADCASTS, MUSIC, CHAT AND M...
19/05/2026
The winner of Thomson Foundation's Young Journalist of the Year 2025, Tracy Bonareri Onchoke, and runner up Wangu Kanuri enjoyed a three-day trip to London ...
19/05/2026
Cisco and the USGA have announced a multiyear extension of their partnership, which began in 2018. Cisco serves as the Official Technology Partner of the USGA, ...
19/05/2026
Urban Edge Network (UEN), a streaming platform for NAIA sports, has announced a partnership with Spiideo to provide streaming and production tools to UEN's ...
19/05/2026
Warner Bros. Discovery (WBD) will provide live coverage of all 900 Roland-Garros matches across its platforms beginning with qualifiers on May 18. In Europe, 21...
19/05/2026
Tubi, Fox Corporation's free streaming service, has announced the launch of the FIFA World Cup 2026 FOX Hub, a dedicated destination for World Cup programmi...
19/05/2026
Telef nica, in collaboration with Sony, has conducted a 5G connectivity trial at the Movistar Arena in Spain using the 26 GHz millimetre wave (mmWave) band. The...
19/05/2026
Ross Production Services (RPS) has installed a Calrec Argo M console into its new Hypermax-1 remote production truck, replacing one of three Argo S consoles pre...
19/05/2026
Panasonic Projector and Display Corporation has announced the acquisition of 100% of the shares of UK-based media technology company Hive Media Control Ltd. (HI...
19/05/2026
Globecast has announced the completion of a nine-month renovation of its Singapore facility, converting it from a traditional linear broadcast operation into a ...
19/05/2026
Grass Valley has announced a three-year enterprise agreement with Phoenix Broadc...
19/05/2026
Bitmovin has announced that Watch Brasil, a streaming platform operating across Brazil and Europe since 2018, has replaced its legacy systems with Bitmovin'...
19/05/2026
Ateme has announced the migration of Dish Home Nepal's Nepal Premier League (NPL) streaming infrastructure to Ateme's TITAN Live solution deployed on Ak...