Creating Erratic Motion Effects with Random Expressions in After Effects

Use the random expression with posterizeTime to create erratic, jumpy motion by setting a frame rate and defining minimum and maximum values.

Create erratic, randomized motion in After Effects by using the random expression in combination with posterizeTime. This approach allows you to control the speed and intensity of changes, resulting in jumpy, non-continuous motion ideal for dials, switches, or any property you want to animate unpredictably.

Key Insights

  • The random expression in After Effects generates non-continuous, jumpy motion between specified minimum and maximum values, making it different from wiggle, which interpolates between values.
  • To control the speed of the random changes, use the posterizeTime expression above the random line to set a custom frame rate such as 10 or 5 frames per second; this slows the rate of change while maintaining the randomness.
  • Noble Desktop demonstrates how random overrides existing keyframes, making it best suited for effects that don't require transitions between specific values and is applicable to properties like rotation, scale, and opacity.

This lesson is a preview from our After Effects Certification Course Online (includes software & exam). Enroll in a course for detailed lessons, live instructor support, and project-based training.

In this video, we'll be looking at the random expression, which can be used to add like random motion to something. It's a bit more like random or rough than wiggle. Wiggle actually runs through every value in between random.

You can really pick different values. So it's a lot more like kind of aggressive, a lot more like off and on, I guess is the way to say it. So it's the gauge.

Is it the gauge? Let's see which layer I'm doing. No, it's actually the, the dial right here. Okay.

So I want to rotate this, but I want to again, put its anchor point right in the middle. This is an example of where snap is annoying. We turn it off.

I'm just going to eyeball the center of the circle about right there. I think I'll just test it. See that rotation works.

After Effects Bootcamp: Live & Hands-on, In NYC or Online, Learn From Experts, Free Retake, Small Class Sizes,  1-on-1 Bonus Training. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.

Yeah, it's pretty good. I like that. That's a pretty nice.

Actually. Let me reset rotation back to just kind of like roughly in the center, basically. That's just where I want to put it.

Okay. So that was option slash or ALT slash on windows, which is the command to fit back in window. You can also do it using the magnification menu in the lower left fit up to is the command I used.

So I just want to randomize this. So I'm gonna hold down option or ALT on windows and click on the stopwatch next rotation. That's how you add expressions.

And by the way, if you hover over the stopwatch, I'll tell you, that's how you add expressions option or ALT click the stopwatch. Now expressions themselves can only be written in the expression text field, which is only in the timeline. The default text that gives you needs to be removed.

It's just dummy text placeholder text to stay there. And I'm just going to add random or in the OEM. And again, it's all lowercase like that easy.

I have to, I don't have to, but I'm going to add two numbers. If I just run random right now, by the way, that's what happens. Okay.

It's, it's randomizing, but it's randomized by a very small amount random by itself, generates a very, very small number. So what I'm gonna do is in the parentheses, right? The minimum maximum numbers is used. Let's say 45 comma negative 45.

And by the way, it doesn't matter which one comes first in this case, because it's rotation. So either one is fine, but it's the minute max values you should take. Now it's going to pick a random number between 45 and negative 45.

So I get that. Okay. A lot more emotion looks pretty good, but it's still the same problem with the speed.

It's really too fast. Now random doesn't have a frequency option the way wiggle does, which means if I want to control the speed of this, I've got to add another line above it. Okay.

So the line I'm at above it, I pressed return at the beginning of random, put my cursor back up above it. It's called posterized time. It's going to add here P O S T R posterized time sets a frame rate, a speed for the expression to run.

Normally random, the reason it's so fast because it's running at the frame rate of the composition. So maybe it's 24,25,30, whatever your 60, whatever your composition is using. It's running that fast.

Okay. Posterized time allows me to set a new frame rate just for this expression. So instead of say 30 frames a second, maybe I'd like this to run at 15 frames a second.

And again, I'm going to the line and press semicolon. So it knows this is the end of this line. Under the same thing we're going to the last line, semicolon.

And like I said, 10 of the last line doesn't need it, but it's a good habit to get introduction to put at the end of all of your lines. But even I don't always follow that habit. Click outside, that finalizes it.

And now it's moving at 15 frames a second rather than 30. So the motion is a lot more erratic. Okay.

This is not going to be anything you want. I mean, you could say one frame a second if you wanted to. Let's try five.

That's nice. So it's that. So I'm getting a lot more erratic motion.

And again, unlike wiggle, which would have rotated through every value in between to settle on a final one, this is literally jumping it. So random is a lot more jumpy than wiggle ever will be. Not bad.

Not bad at all. I think I'm going to settle on a 10 by the way, but it's up to you play with it. Have some fun with that.

Okay. And that's the random property. It can be used on a pretty much anything you want.

Normally, again, you want to specify a minimum maximum value for it to use. Otherwise it just kind of wiggles at a very small place. It's default value I think gives you a value like less than one.

So just keep that in mind. That's pretty good. And again, this kind of dial, this switch kind of pretty good use of random, okay.

Randomly bouncing around. So you could do this for opacity. You could do it for scale.

Pretty much anything you want works really pretty nicely, really pretty well. When you want to add that kind of like erratic randomized motion, this can be a really helpful tool for you. Again, if you need the dial or whatever it is to its specific values, use key frames.

Random is an example of one of the expressions that completely overrides any key frames you already have. If you had key frames, not going to care. It's going to override them at the random function.

So pretty much that's how you use random. Posterized time can be used with other expressions. Again, very commonly it's tied with random specifically for this to be able to control its speed.

The other thing to keep in mind is that posterized time had to come first. If I tried to put it after random, the expression would have failed. Posterized time setting the frame rate is pretty much going to be the first line in this case, and then random and what else you want to add.

And that's how to use random and posterized time to create a nice little erratic movement effect.

Jerron Smith

Jerron has more than 25 years of experience working with graphics and video and expert-level certifications in Adobe After Effects, Premiere Pro, Photoshop, and Illustrator along with an extensive knowledge of other animation programs like Cinema 4D, Adobe Animate, and 3DS Max. He has authored multiple books and video training series on computer graphics software such as: After Effects, Premiere Pro, Photoshop, Illustrator, and Flash (back when it was a thing). He has taught at the college level for over 20 years at schools such as NYCCT (New York City College of Technology), NYIT (The New York Institute of Technology), and FIT (The Fashion Institute of Technology).

More articles by Jerron Smith

How to Learn After Effects

Master After Effects with Hands-on Training. After Effects is the Industry-standard Application for Motion Graphics, Animation, and Visual Effects.

Yelp Facebook LinkedIn YouTube Twitter Instagram