
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
06/10/2025
France T l visions, France's leading broadcaster, has received the 2025 EBU ...
04/09/2025
Monumental Sports & Entertainment (MSE), in collaboration with Dalet, has been a...
16/06/2025
By Bailey Pennick
One of the most exciting things about the Sundance Film Festi...
16/06/2025
The Cannes Lions International Festival of Creativity is officially underway for...
16/06/2025
On Spotify, francophone content continues to cross borders at an unprecedented rate. In 2024 alone, more than 123 million listeners worldwide streamed audio con...
16/06/2025
TYSONS, Va. Tegna Inc. is embarking on a notable expansion of their already substantial local news programming by launching live and on-demand, local newscasts ...
16/06/2025
Netflix has announced that it is expanding its global programmatic ad offerings by partnering with Yahoo DSP. This will enable brands to buy Netflix advertising...
16/06/2025
Instrument now boasts full NKS support
Sub51 and Soundtrax have just announced the launch of an updated and improved version of their innovative sample-base...
16/06/2025
NEW YORK In a landmark agreement to overtake the burgeoning connected TV (CTV) advertising market, Amazon Ads and Roku today announced a new integration that gi...
16/06/2025
ATLANTA, BALTIMORE, CINCINNATI and IRVING, Texas The four major broadcast groups behind the ATSC 3.0-based EdgeBeam Wireless datacasting joint venture today nam...
16/06/2025
BURLINGTON, Mass. Avid today announced an extended agreement with Amazon MGM Studios to integrate Avid's Media Composer and Avid NEXIS on Amazon Web Service...
16/06/2025
Maxon, maker of powerful, approachable software for creators working in 2D and 3D design, motion graphics, visual effects, gaming and more, today announced the ...
16/06/2025
Alfalite, the only European manufacturer of LED displays, announces the launch of SKYPIX RGBW & IM, a new series of ceiling-mounted LED panels designed specifi...
16/06/2025
Two new compact 4HP modules introduced
ALM/Busy Circuits have just announced the launch of two new Eurorack modules, the Pip Filter and Pip LFO, both of whi...
16/06/2025
16 Jun 2025
VEON Announces USD 35 Million Share Buyback Announcement marks the third phase of USD 100 million share buyback program
Dubai, June 16, 2025: VEON...
16/06/2025
Save 40% or More on All Ivory II Collections!From now through June 30th, enjoy huge savings on all Ivory II Piano Collections. Our biggest discounts ever are be...
16/06/2025
Behind The Broadcast Booth, Ep. 3: Golf. My Future. My Game. Founder and CEO Cra...
16/06/2025
The REMI Revolution Is Here: How Remote Production Technology in Esports Pioneer...
16/06/2025
From Super Bowl to Indy 500, New Orleans Artist Frenchy' Captures Energy of...
16/06/2025
NFL Films Enhances Post Studio With Dolby Atmos Audio Forty-three channels of audio enable the facility to migrate to immersive By Dan Daley, Audio Editor
Mo...
16/06/2025
SVG New Sponsor Spotlight: Storj's David Colantuoni on Expanding Cloud-Based...
16/06/2025
Grass Valley 4K Cameras Head to Greece for View Master Events' New OB Truck By Ken Kerschbaumer, Editorial Director
Monday, June 16, 2025 - 2:33 pm
Pri...
16/06/2025
Monday 16 June 2025
Sky Arts' Access All Arts Week, a free nationwide arts ...
16/06/2025
Monday 16 June 2025
Families and children are invited to dress up, have fun and raise money to protect nature
WWF UK and Sky Kids are teaming up to launch Wea...
16/06/2025
The Rohde & Schwarz R&S M3AR radio family reaches 10,000 unit milestone, demonst...
16/06/2025
FOX Advertising Launches Enhanced Brand Storytelling Program with Strategic Inve...
16/06/2025
Run with Ray is back! RT Radio 1's The Ray D'Arcy Show hits the road th...
15/06/2025
July 2025 in Dublin, Berlin, Amsterdam & London
Photo: Thea Martre
Music Production for Women (MPW) have announced that they will be running a series of fo...
15/06/2025
Composer/producer launches free virtual instruments
Sulcata Sound is the latest venture of Jason Graves, a two-time British Academy Award-winnning composer,...
14/06/2025
NEW YORK Pluto TV and the All Womens Sports Network have launched a free ad-supported streaming TV (FAST) AWSN channel in the U.S., Canada, the U.K. and the Nor...
14/06/2025
NEW YORK and CINCINNATI E.W. Scripps has announced a new, multiyear agreement with the WNBA that will continue Ions regular-season coverage of the league on Fri...
14/06/2025
WASHINGTON The National Association of Broadcasters highlighted the hidden importance of spectrum in the production of major sporting events and described wha...
14/06/2025
WASHINGTON Sunsetting ATSC 1.0, expanding business opportunities for NextGen Broadcast and increasing international adoption of the ATSC 3.0 standard were top o...
14/06/2025
SAN FRANCISCO Samba TV and Acxiom have announced that they will dramatically expand their longstanding relationship....
14/06/2025
July 2025 in Dublin, Berlin, Amsterdam & London
Photo: Thea Martre
Music Production for Women (MPW) have announced that they will be running a series of fo...
14/06/2025
San Francisco State University's School of Cinema Uses Blackmagic Design
Brie Clayton June 13, 2025
0 Comments
More than 40 Blackmagic Design came...
14/06/2025
Boris FX Mocha Pro Adds New AI Tools To Tackle VFX Tasks Fast
Jessie Electa Petrov June 13, 2025
0 Comments
The 2025.5 release helps artists work more...
14/06/2025
AJA Debuts DRM2-Plus Mini-Converter Frame at InfoComm 2025
Brie Clayton June 13, 2025
0 Comments
Next-gen frame addresses diverse rackmount needs wit...
13/06/2025
(L-R) Lindsay Utz, Michelle Walshe, and The Right Honourable Dame Jacinda Ardern attend the 2025 Sundance Film Festival premiere of Prime Minister at Eccles T...
13/06/2025
Photo credit: Atsushi Nishijima
If you're a true lover of rom-coms, chances...
13/06/2025
Pure Drama and Fierce Rivalries set to dominate the world's most iconic spor...
13/06/2025
Johannesburg, 12 June 2025 - The National Film and Video Foundation (NFVF), an a...
13/06/2025
ABILENE. Texas A severe storm knocked down the tower and severely damaged the news studio and main facility of Sinclair-owned KTXS here on Sunday, June 8....
13/06/2025
Berklee's Music Business/Management Department Recognized by the Music Biz A...
13/06/2025
WASHINGTON The ATSC, the Broadcast Standards Association, honored veteran technologist Aldo Cugnini and Clarence Hau, Senior Vice President of Standards, Policy...
13/06/2025
(Editor's note: The 2025 UFL Championship Game between the D.C. Defenders and Michigan Panthers kicks off Saturday, June 14, at 8 p.m. Eastern. The game wil...
13/06/2025
New iPad/iPhone synth App announced
Following on from last year's release of Gradient Synth - which reached #6 on the App Store's Paid Music charts ...
13/06/2025
LONDON Warner Bros. Discovery has announced that HBO Max will launch direct-to-consumer in multiple new countries this July as the streamer becomes available in...
13/06/2025
AI voice transcription and captioning platform Verbit has added a new feature to its Captivate ASR solution the ability to identify specific features in automat...
13/06/2025
WASHINGTON Federal Communications Commission member Anna Gomez has wrapped up two weeks in California visiting broadcasters, television studio executives, enter...