Sony Pixel Power calrec Sony

Generating Random Motion Using AE 5.5's Expressions

26/07/2023

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
LINK: https://creativecow.net/generating-random-motion-using-ae-5-5s-express...
See more stories from creativecow

Most recent headlines

05/01/2027

Worlds first 802.15.4ab-UWB chip verified by Calterah and Rohde & Schwarz to be demoed at CES 2026

Worlds first 802.15.4ab-UWB chip verified by Calterah and Rohde & Schwarz to be ...

01/06/2026

Dolby Sets the New Standard for Premium Entertainment at CES 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...

02/05/2026

Dalet Flex LTS Delivers Smarter Search, Faster Editing, and an AI-Ready Foundation for Modern Media

Dalet, a leading technology and service provider for media-rich organizations, t...

01/05/2026

NBCUniversal's Peacock to Be First Streamer to Integrate Dolby's Full Suite of Premium Picture and Sound Innovations

January 5 2026, 18:30 (PST) NBCUniversal's Peacock to Be First Streamer to ...

01/04/2026

DOLBY AND DOUYIN EMPOWER THE NEXT GENERATON OF CREATORS WITH DOLBY VISION

January 4 2026, 18:00 (PST) DOLBY AND DOUYIN EMPOWER THE NEXT GENERATON OF CREATORS WITH DOLBY VISION Douyin Users Can Now Create And Share Videos With Stun...

21/02/2026

OBS CTO Sotiris Salamouris on the Legacy of the 2026 Winter Games

With Software Defined Broadcasting more established in Milan Cortina look for Los Angeles 2028 to have less hardware and more cloud-based software systems...

21/02/2026

Invisible String: NBC Olympics' Marsha Bird on the Hidden Work That Makes the Games Shine

The SVP of Olympic Operations on turning CAD drawings into reality, building tru...

21/02/2026

NAB Urges FCC to Tamp Down Reallocation Plans for Upper C-Band

Share Copy link Facebook X Linkedin Bluesky Email...

21/02/2026

Chyron Paint 10.3 Adds New Visualization Features for Live Action

Share Copy link Facebook X Linkedin Bluesky Email...

21/02/2026

Netflix Unveils the Trailer of Accused', A Psychological Drama on Power, Perception and Public Judgment

Back to All News Netflix Unveils the Trailer of Accused', A Psychological ...

20/02/2026

Gravity Media, Green Couch Entertainment Partner to Create Original Programming for International Broadcasters

Gravity Media and Los Angeles-based Green Couch Entertainment announce a strateg...

20/02/2026

IMAX, Apple TV Bring 2026 FIA Formula One World Championship Races to Selected U.S. Locations

IMAX announces it is working with Apple TV to bring the 2026 FIA Formula One Wor...

20/02/2026

Big Upgrade to Spring Training Experience With New Daktronics Displays at Phillies' BayCare Ballpark

Daktronics has partnered with the Philadelphia Phillies to design, manufacture, ...

20/02/2026

ESPN To Launch Women's Sports Sundays, a New Summer Weekly Primetime Franchise

ESPN announces the upcoming launch of Women's Sports Sundays - a first-of-it...

20/02/2026

Sennheiser Spectera Handheld Makes Broadcast Debut at Super Bowl LX

As the Seattle Seahawks and New England Patriots faced off in the NFL's biggest sporting event of the season on Sun., Feb. 8, Sennheiser wireless solutions ...

20/02/2026

ESPN To Stream More MLB Spring Training Games Than Ever in 2026

ESPN announces its 2026 Major League Baseball spring training schedule, which includes four national games on ESPN, six games on ESPN Unlimited, and more than 2...

20/02/2026

Open Broadcast Systems Launches 200 Gigabit Ethernet

Open Broadcast Systems, which specializes in software-based professional video transport, has added support for 200 Gigabit Ethernet to its range of encoders an...

20/02/2026

Chyron PAINT 10.3 Adds New Ways To Visualize Live Sports

Chyron announces the release of PAINT 10.3, which is designed to help analysts and operators turn live action into clearer, faster on-air storytelling. PAINT 1...

20/02/2026

Live Spring Training Games Begin Feb. 20 on MLB Network With Yankees Against Orioles

With full squad workouts underway, MLB Network's live Spring Training game s...

20/02/2026

MLS Kickoff 2026: As FIFA Men's World Cup Looms, League's Media Operations and Apple TV Aim To Enhance Viewing Experience

Tech enhancements, marquee productions are expected to take advantage of a summe...

20/02/2026

SVG GameDay, Ep. 4: Temple Athletics' Paige Wisehaupt - Driving Digital Content for the Cherry & White

In-venue and creative video staffers at the professional and collegiate level ha...

20/02/2026

BBC Sport's Focus on Clips, Social Media and a Highlights-Free Games

Speaking with SVG Europe after one of Team GB's greatest days at a Winter Olympics, BBC Sport's head of major events, Ron Chakraborty, explains the broa...

20/02/2026

Warner Bros. Discovery on Making Olympic Magic for Multiple Local Markets From Its Studios in Cortina and Livigno

Making Winter Games Olympic magic is the goal for every broadcaster in Italy cov...

20/02/2026

OBS Curling Directors Brie Robertson and Susan Young Talk Olympic Experiences and Keeping the Story Going with the Lights Out

Curling, one of the least-dangerous Winter Olympic sports, is dominating the Mil...

20/02/2026

How Digital First' Goals Are Bringing Together Linear and Online Editorial for BBC Sport Coverage at the Winter Olympics

BBC Sport's presence at the 2026 Winter Games is centred around a significan...

20/02/2026

Pinning Digital Content Onto the Backbone of a Strong Linear Infrastructure for BBC Sport in Cortina

BBC Sport is bringing together its linear TV and streaming digital arms in a str...

20/02/2026

BBC Sport Talks Influencers and Athletes in its Bid to Pivot to a Digital First' Strategy for the Games

To broaden the appeal of winter sports at Milano Cortina, the BBC has integrated...

20/02/2026

DIRECTV Adds Apple TV's Formula 1 Racing for Residential and DIRECTV FOR BUSINESS Customers

Just in time for the start of Apple TV's inaugural season as the exclusive U...

20/02/2026

NBC Olympics VP Creative David Barton Dives into Milano-Cortina 2026 Graphics Package, Now You Know' Animations

One big challenge was to depict the character of each of very different and wide...

20/02/2026

By Design Director Asks Festival Audience to Flirt With Their Chairs at Premiere

(L-R) Writer-director Amanda Kramer photographs the photographers at the premiere of her film By Design at the Library Center Theatre in Park City. (Photo by ...

20/02/2026

When Memory Gets Expensive, Is it Time to Swap the Box?

In our latest blog, Tim Pearson explores the impact that increased memory prices are having on the consumer electronics market, and particularly the set-top box...

20/02/2026

Calrec Type R: Shaping the Future of Radio at Flirt FM

Calrec Type R: Shaping the Future of Radio from the Heart of Flirt FM Love may have filled the airwaves last week for Valentine's Day, and we've just c...

20/02/2026

Super Bowl LX Delivers 125.6 Million Viewers

NEW YORK - February 10, 2026 - An estimated 125.6* million viewers watched Super Bowl LX on Sunday, February 8, according to Nielsen's Big Data Panel meas...

20/02/2026

Nielsen: Super Bowl LX Final Viewership Rises to 125.6 Million Viewers with Verified Big Data

NEW YORK - February 19, 2026 - Nielsen today shared updated and final Super Bowl...

20/02/2026

NHPBS Taps Heartland Video Systems for ATSC 3.0 Launch

Share Copy link Facebook X Linkedin Bluesky Email...

20/02/2026

Lightware and Cisco interoperability brings AV system suc...

A leading global investment bank, with offices at Two International Finance Centre in Hong Kong, partnered with systems integrators Global Vision Engineering (G...

20/02/2026

Rise AV and Rise Broadcast unite for International Womens...

Rise AV and Rise Broadcast, the global not-for-profit organisations dedicated to improving gender diversity across technical industries, have today announced a ...

20/02/2026

Open Broadcast Systems launches Two Hundred Gigabit Ether...

Open Broadcast Systems, the leader in software-based professional video transport, has added support for 200 Gigabit Ethernet to its range of encoders and decod...

20/02/2026

Signiant Launches Customer Advisory Board to Help Shape t...

Signiant today announced the formation of its Customer Advisory Board (CAB), bringing together a select group of customers to collaborate on product strategy, r...

20/02/2026

PTZOptics launches its Visual Reasoning initiative and pa...

PTZOptics today announced the launch of its Visual Reasoning initiative that makes video more actionable by combining robotic PTZ camera systems, AI, and open i...

20/02/2026

DELTA and Amino Complete Certification of Amigo 7N Androi...

Amino, a global media technology provider delivering devices, software and cloud services that simplify and elevate video delivery, today announced the successf...

20/02/2026

SMPTE Opens Call for Papers for 2026 Media Technology Sum...

SMPTE , the home of media professionals, technologists, and engineers, today announced its call for technical papers for the SMPTE 2026 Media Technology Summit....

20/02/2026

Granicus Standardizes Hybrid Government-Grade Video Infra...

Wowza Media Systems today announced that Granicus, a leading provider of digital engagement solutions for governments, continues to rely on Wowza to power its h...

20/02/2026

CBS Baltimore Launches New AR/VR Studio

Share Copy link Facebook X Linkedin Bluesky Email...

20/02/2026

IAB Tech Lab Opens Public Comment on Live Event Ad Playbook

Share Copy link Facebook X Linkedin Bluesky Email...

20/02/2026

Study: Sports Programming on Major Streamers Up 52% YoY

Share Copy link Facebook X Linkedin Bluesky Email...

20/02/2026

ESPN to launch Women's Sports Sundays

Share Copy link Facebook X Linkedin Bluesky Email...

20/02/2026

Tegna, Seattle Kraken Extend Broadcast Deal

Share Copy link Facebook X Linkedin Bluesky Email...

20/02/2026

Signiant Announces Customer Advisory Board

Share Copy link Facebook X Linkedin Bluesky Email...