
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
20/12/2025
Atomos announced the immediate availability of a new firmware update for its Ninja TX GO and Ninja TX monitor-recorders, unlocking ProRes RAW recording from the...
20/12/2025
CJP Broadcast has completed the digitisation of the European Gymnastics tape archive, converting 328 tapes containing more than forty years of recorded material...
20/12/2025
Bitmovin, the leading provider of video streaming solutions, today announced the launch of the Stream Lab MCP Server, to give AI agents and large language model...
20/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
20/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
20/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
20/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
20/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
20/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
20/12/2025
Barack Obama Includes Laufey on His 2025 Favorite Music List The former presidents roundup of books, music, and movies includes a song from the Berklee alums ...
20/12/2025
Study reveals a key hormonal circuit in the kidneys Scripps Research scientists identify the protein that helps kidney cells regulate renin, providing foundatio...
19/12/2025
With Playout Release 2025.4, ToolsOnAir continues to push professional playout w...
19/12/2025
SVG Sit-Down: Diversified's Jared Timmins on AI for Broadcast Sports and Cre...
19/12/2025
2025 SVG Summit Audio Recap: Say What?The Audio Production and Distribution Workshop at the SVG Summit 20 took on issues including speech intelligibility, Next-...
19/12/2025
Gamified fun: Channel 5 on its NFL Big Game Night ambitions with Hungry Bear Med...
19/12/2025
College Football Playoff Preview: For ESPN, Round 1 is a Fantastic Yet Familia...
19/12/2025
AWS's Jason Dvorkin on Developing Partnerships With the NBA and PGA Tour, Em...
19/12/2025
Netflix Kicks Off Packed Sports Week with Paul-Joshua Fight Before Shifting to N...
19/12/2025
SVG New Sponsor Spotlight: Presidio's Nareev Shah on the Role of Its Captiva...
19/12/2025
Mounted to the pylon of an AH-1Z Viper helicopter, a Red Wolf vehicle successful...
19/12/2025
L3Harris technology for the SDA Tranche 3 Tracking Layer program will provide in...
19/12/2025
Partnership brings Nielsen ONE measurement activation directly into XR's adv...
19/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
19/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
19/12/2025
Berklee Announces Spring 2026 Signature Series This season's highlights include the Gospel Extravaganza, the 40th International Folk Festival, special gue...
19/12/2025
Performing arts centres across the globe have doubled down on live production infrastructure in recent years. For venues like the Queensland Performing Arts Cen...
19/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
19/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
19/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
19/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
19/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
19/12/2025
Share Share by:
Copy link
Facebook
X
Whatsapp
Pinterest
Flipboard...
19/12/2025
Ricardo Coke-Thomas Named Chair of Theater for Boston Conservatory at Berklee The distinguished theater educator, director, and performer will join the Conser...
19/12/2025
Back to All News
Salvador Arrives to Netflix on February 6
Entertainment
19 December 2025
GlobalSpain
Link copied to clipboard
WHEN THERE IS NOTHING LEFT ...
19/12/2025
As the year comes to a close, it's the perfect time to give your WO Automation for Radio system a quick tune up. At the top of your year end checklist is on...
19/12/2025
19 Dec 2025
VEON's Mobilink Microfinance Bank Launches Islamic Banking Oper...
19/12/2025
Wrapping up a year of connection and clarity!
19 Dec Written By Suzanne Costello
As 2025 comes to a close, we want to take a moment to thank our incredib...
19/12/2025
The six-part drama, set in a close-knit Welsh town fractured by an unspeakable c...
19/12/2025
Rohde & Schwarz drives the future of mobility at CES 2026 At the 2026 Consumer Electronics Show in Las Vegas, Rohde & Schwarz will present a powerful lineup o...
19/12/2025
Back to All News
Salvador arrives to Netflix on February 6
Entertainment
19 December 2025
GlobalSpain
Link copied to clipboard
WHEN THERE IS NOTHING LEFT ...
19/12/2025
Back to All News
Last Samurai Standing' Renewed for Season 2 - A Global Se...
19/12/2025
RT is proud to return to the RDS to support the 2026 Stripe Young Scientist & T...
19/12/2025
Nanoparticle vaccine strategy could protect against Ebola and other deadly filoviruses Scripps Research scientists turn nanoparticles into virus showcases to ...
18/12/2025
SVG Campus Shot Callers: Kurt Sutton, Director of Broadcast Operations, Clemson ...
18/12/2025
Follow the Money Episode 2: Inside the Sports Media Biz with Sam McCleery and St...
18/12/2025
SVG Sit-Down: Google Cloud's Anshul Kapoor on the Future of Generative Prod...
18/12/2025
The 2025 SVG Summit Draws Record Crowd for 20th-Annual Sports-Production Industr...
18/12/2025
SBS's sports schedule sizzles in January with Dakar Rally, Kooyong Classic a...
18/12/2025
Canada's largest indoor arena has transformed its live production capabilities with a full ST 2110 infrastructure and Calrec's compact Argo S console. S...
18/12/2025
During November, streaming's share of TV viewing in Mexico settled at 24.2%, an increase of 0.5 share points from the previous month.
Disclaimer: YUMI TV,...