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 ...

07/10/2026

Dalet Flex LTS Delivers Smarter Media Operations from Ingest to Distribution

Dalet, a leading technology and service provider for media-rich organizations, today announced the latest Long-Term Supported (LTS) release of Dalet Flex. Build...

06/09/2026

Dolby and MagentaTV Bring Fans Closer to the FIFA World Cup 2026 in Germany with Dolby Vision and Dolby Atmos

June 9 2026, 23:00 (PDT) Dolby and MagentaTV Bring Fans Closer to the FIFA Worl...

20/08/2026

MS Now to Launch $7.99 DTC Service

Share Copy link Facebook X Linkedin Bluesky Email...

20/08/2026

Nielsen Details Improvements to Audience Measurement Capabilities

Share Copy link Facebook X Linkedin Bluesky Email...

20/08/2026

Study: 174 Billion Illegal Streams During FIFA World Cup 2026

Share Copy link Facebook X Linkedin Bluesky Email...

20/08/2026

Prasad Opens New 8K/4K Film Preservation & Restoration Center

Share Copy link Facebook X Linkedin Bluesky Email...

20/08/2026

IPC Expands Brazilian Presence with New Channel Partner C...

IPC Expands Brazilian Presence with New Channel Partner CCATech Industry veterans Carlos Abrah o and Bruno Lopes strengthen local support and expand IPCs prese...

20/08/2026

Zixi Enters Mauritius Market Through Strategic Deployment...

Zixi Enters Mauritius Market Through Strategic Deployment with MTC Jockey Club Worlds Oldest Horse Racing Club in the Southern Hemisphere Selects Zixis Softwar...

20/08/2026

Scripps Research scientist to receive $2.76 million NIAID New Innovators Award

LA JOLLA, CA-Scripps Research assistant professor Tiantian Liu has received a five-year NIAID DP2 award from the National Institute of Allergy and Infectious Di...

20/08/2026

Audiences reveal appetite for multicultural Australia on-screen

Audiences reveal appetite for multicultural Australia on-screen 20 August 2026 Dr Georgie McClean, Dr Rebecca Huntley (L-R) By Dr Georgie McClean and Dr Rebec...

20/08/2026

How Mavis Studio Is Expanding Live Production Teaching at Sussex

How Mavis Studio Is Expanding Live Production Teaching at Sussex Brie Clayton August 19, 2026 0 Comments Hero image displays a student about to mix be...

20/08/2026

Vertical Unscripted Series Legal Queens Captured with Blackmagic Design

Vertical Unscripted Series Legal Queens Captured with Blackmagic Design Brie Clayton August 19, 2026 0 Comments Reality TV veteran Eric Gardner create...

19/08/2026

Imagine Communications Steve Reynolds on Kaseya Centers Hybrid IP Build and the Growth of ST 2110

As the cost of IP nears price parity with traditional SDI, Reynolds argues that ...

19/08/2026

European Athletics Championships 2026: BBC, Event Organizers Bring Birmingham Action to Viewers in Style

A private 5G bubble was chosen instead of traditional broadcast RF for the race ...

19/08/2026

Filipiana Sets the Class Divide on a Golf Course in the Philippines

(L-R) Rafael Manuel and Isabel Sicat attend the Filipi ana premiere during the 2026 Sundance Film Festival at The Ray Theatre on January 23, 2026, in Park Cit...

19/08/2026

MPG launch Save Our Studios survey

Studio owners invited to have their say on rates cuts The Music Producers Guild (MPG) are inviting UK-based studios to take part in an in-depth survey that ...

19/08/2026

Harrison unveil the Flex-10

Vintage-inspired desktop interface revealed Harrison's latest hardware offering sees them head into the world of audio interfaces, delivering a 10-in/12...

19/08/2026

Minimal Audio release Lucid

Granular effect remains locked to scale and tempo Described as your dream granular effect , Minimal Audio's latest creation is capable of turning any s...

19/08/2026

Audio Modeling open PolySWAM pre-orders

First polyphonic SWAM instrument incoming Audio Modeling's latest physical-modelling orchestral instrument is just around the corner, and is now availab...

19/08/2026

FOX and NBCUniversal Score with FIFA World Cup 2026 Success in Nielsen's June Gauge Reports

World Cup Games Generate 84 Billion Minutes Across FOX, Fox Sports 1 and NBCU...

19/08/2026

The Gauge: Poland | July 2026

July brought typical peak-holiday drops in viewership, driven primarily by viewers stepping away from screens and a visible decline in reach across both traditi...

19/08/2026

Carr Calls ABC Suit 'Meritless

Share Copy link Facebook X Linkedin Bluesky Email...

19/08/2026

Henry Alexander Joins BCE as Sales Director

Henry joins BCE as the company accelerates its commercial strategy and expands its international presence across the media, broadcast and technology markets. He...

19/08/2026

iWedia Announces Advanced Android DRAM Optimisation Proce...

iWedia, a leading provider of software solutions for connected TV devices, today announced a major milestone in Android platform optimization with the successfu...

19/08/2026

NTP Technology announces ST 2110-30-RAVENNA 128-channel A...

NTP Technology announces that ST 2110-30 audio-over-IP connectivity with AES67 and RAVENNA capabilities is now available for the brand's world-class audio i...

19/08/2026

ORF goes full IP with Net Insight in nationwide network o...

Net Insight has been selected to provide its Nimbra platform by the service provider Big Blue Marble, formerly ORS Group, as the core media transport solution f...

19/08/2026

Coventry City Trophy Parade Extends LiveU LIQ Beyond the...

LiveU has supported Coventry City FC and several other top-flight UK football clubs through one of their most demanding live production challenges of the year, ...

19/08/2026

Nature Seekers Documentary Shot with Blackmagic URSA Cine 12K LF

Nature Seekers Documentary Shot with Blackmagic URSA Cine 12K LF Brie Clayton August 18, 2026 0 Comments Filming endangered turtles required camera...

19/08/2026

Neyrinck Brings D-Control Consoles Back to Life on Apple Silicon with D-Control Basic

Neyrinck Brings D-Control Consoles Back to Life on Apple Silicon with D-Control ...

19/08/2026

ABC Files First Amendment Lawsuit Against FCC

Share Copy link Facebook X Linkedin Bluesky Email...

19/08/2026

Nielsen: Fox and NBCUniversal Score with FIFA World Cup 2026

Share Copy link Facebook X Linkedin Bluesky Email...

19/08/2026

ESPN Co-Founder Bill Rasmussen Dies At 93

Share Copy link Facebook X Linkedin Bluesky Email...

19/08/2026

Study: NBA Ad Revenue Hit $2.1 Billion Last Season

Share Copy link Facebook X Linkedin Bluesky Email...

19/08/2026

Nexstar's WNCN Donates ENG Van for Training

Share Copy link Facebook X Linkedin Bluesky Email...

19/08/2026

Riedel Brings Professional Live Production Into the Class...

Riedel Communications today announced that Edith Cowan University (ECU) in Perth, Australia, implemented a comprehensive communications infrastructure that brin...

19/08/2026

QuickLink Showcases New 4K Capabilities Across StudioEdge...

QuickLink, a leading provider of award-winning video production and remote guest contribution solutions, will spotlight a major leap forward in remote guest con...

19/08/2026

EMAM together with PlayBox Neo and SNEWS launch combined...

Integrated platform melds media asset management, playout automation and newsroom workflows EMAM, PlayBox Neo and SNEWS have officially launched Nuvex, a conne...

19/08/2026

Screen Australia releases the Private Investment Toolkit to strengthen screen industry financing pathways

Screen Australia releases the Private Investment Toolkit to strengthen screen in...

19/08/2026

Do Aussies truly value local content? Unpacking Screen Currency 2026 with Deirdre Brennan

Do Aussies truly value local content? Unpacking Screen Currency 2026 with Deirdr...

19/08/2026

U&alibi re-commissions Bookish for Christmas Special and Series 3

There's an early Christmas gift for Bookish fans, as UKTV confirms the re-commission of the hit U&alibi drama, created by and starring Mark Gatiss. Viewers ...

19/08/2026

Sky gives sports fans the chance to watch multiple live sports events simultaneously on the big screen for the first time

Wednesday 19 August 2026 Sky gives sports fans the chance to watch multiple liv...

19/08/2026

RT TO AIR HISTORIC KATIE TAYLOR FIGHT IN CROKE PARK

On Saturday September 5 Katie Taylor will step into the ring for the fight of her life against Flora Pili in front of 80,000 fans in Croke Park. A legendary fig...

18/08/2026

SportStream 2026 Virtual Event Set for September 15-17

SportStream 2026, a free three-day virtual event, will take place September 15-17. One registration provides access to all three days of live programming and on...

18/08/2026

IBC 2026: BeckTV to Debut BeckFlow Documentation Platform

BeckTV will introduce BeckFlow to the European market at IBC2026, demonstrated on the Providius stand (10.F53). BeckFlow is a web-based schematic documentation...

18/08/2026

IBC 2026: Boland Communications to Introduce ST 2110 Option for 4K Monitors

Boland Communications will introduce a SMPTE ST 2110 input option for its 4K monitors at IBC2026, along with a new 55-inch super-narrow bezel display for video ...

18/08/2026

Seattle Seahawks Integrate Dolby OptiView with Dolby Vision for Fan Streaming

Dolby Laboratories and the Seattle Seahawks have announced a partnership integrating Dolby OptiView into the Seahawks' live streaming coverage, making the S...

18/08/2026

Insights from BMG's Graham Taylor on the Role of a Sports Producer in Live Broadcast Production

For BMG Executive Producer of Sports Production, Graham Taylor, producing live s...

18/08/2026

TMRW Sports Names Rufus Hack as President of Golf

TMRW Sports has appointed Rufus Hack as President of Golf, a newly created role in which he will lead the company's golf businesses including TGL presented ...