New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

The wiggle expression

From: After Effects Apprentice 09: Expressions

Video: The wiggle expression

Next, I'd like to show you our favorite expression of all, Wiggle. First I'll clean up my display by closing all of my previous comps and open up 05-wiggle*starter. In it I just have a little gizmo in the middle of my screen just doing his own little animation. Let's say I want this gizmo to wander around the screen. In other words, I want to wiggle its position. I'll type P to reveal the position value, hold down Option or Alt to enable expressions for Position, click, and in place of the default expression transform.position, I am going to type wiggle, open parentheses, and I need to enter two numbers, how fast I want to wiggle and how much I want to wiggle by.

The wiggle expression

Next, I'd like to show you our favorite expression of all, Wiggle. First I'll clean up my display by closing all of my previous comps and open up 05-wiggle*starter. In it I just have a little gizmo in the middle of my screen just doing his own little animation. Let's say I want this gizmo to wander around the screen. In other words, I want to wiggle its position. I'll type P to reveal the position value, hold down Option or Alt to enable expressions for Position, click, and in place of the default expression transform.position, I am going to type wiggle, open parentheses, and I need to enter two numbers, how fast I want to wiggle and how much I want to wiggle by.

Let's say I only want to wiggle at a pace of one wiggle a second, fairly sedate, and let's say I want to wiggle by 100 pixels. Note that I separated the numbers with a comma. The space is not necessary; I put that in just to make it easier to read. And then close parentheses. Press Enter on numeric keypad, 0 to RAM Preview, and now my gizmo is indeed wandering around my screen. If I want him to wander faster, I increase the 'how fast' number from 1 to 2, RAM Preview.

Now he is much more kinetic and much crazier. If I don't want him wandering by quite as much, I enter a different number, like, say, 50 pixels, Enter, and preview. So now he sticks closer to the side of the screen, although he is wiggling very quickly. I'll go back to where we started, one wiggle a second and 100 pixels of wiggle. Notice that by default you don't see any motion path. We've not keyframed position. We just added wiggle on to the current position.

If you want to see that path, you need to enable the Post-Expression Graph button that we showed you in the previous movie. As soon as I turn that on, you will now see the motion path for the wiggle. As I drag the Current Time Indicator, you'll see him move along that wiggly path. Now you might run into occasions where that path is not long enough. We're not seeing the entire path. If you run into that, go into your Preferences and open Preferences > Display.

This is where you get to pick how long of a motion path you get to see. The default is 15 seconds, centered around your current time. We almost always set this to All Keyframes, so we get to see the entire motion path, no matter how long our composition is. However, if you find that's too much information that's cluttering your display, you can go back to one of these other options. But I am going to click All Keyframes for now. Note that Wiggle adds itself to the current position. You don't need to do plus value; it doesn't that automatically. So if I was going to go back to the start of my composition, I am going to turn off my Post-Expression Graph for now, move my gizmo down into the lower-left corner.

Now if I can turn off the Wiggle expression, so I get a true idea of where he really is, enable keyframing for position, press End to go to the end of the composition, drag him up to the upper right, now I have a very slow animation from the lower left to upper right. Turn the Wiggle expression back on and now he will wiggle along that path. So Wiggle can be used as an offset to create say shaky-cam effects or just more natural random movements.

If I want to see that path, I enable the Post-Expression Graph, and now I see my new modified path, and we'll preview again. Or you just drag the Current Time Indicator along the path to see what's going on. This is another case where the Graph Editor also comes in really handy to visualize what's happening. I am going to enable the Graph Editor. I have my Post-Expression Graph already turned on. If it was turned off, I would just get my flat animation, but now that it's turned on, I am seeing my Speed Graph for Position.

If I want to see the Value Graph for position, I need to go down here underneath Graph Type and change it to Value Graph. I want to see how my red and green lines for my X and Y position values are changing over time. The straight lines are my keyframed position. The curvy lines are with the expression added in. And again, I could turn off that graph or turn it on to see the results. RAM Preview and now you get a graphic representation of what's happening with the wiggle.

I'll turn that off for now. Position is not the only parameter you can wiggle. In fact, you can wiggle virtually any parameter. If you can keyframe it, you can apply an expression to it, and in virtually all cases, that means you can wiggle it. So I am going to type Shift+Plus+R to Reveal Rotation, Option+Alt+Click on the stopwatch to enable expressions. Type wiggle, open parentheses, how fast? Let's do a slow Rotation of 0.5 wiggles per second, or a wiggle gyration every two seconds, comma, and let's wiggle by 45.

The value is always the natural value range of the parameter. Close parentheses, press Enter, and now that only is this little guy flying along his path, he is also rotating randomly as well. He is looking a little bit drunk now, if you ask me, or maybe it's just a high wind. If I want to see him just centered in the screen, I'll just go ahead and turn off my keyframes for Position, but the expression is still enabled unless I was to turn that off as well. Now we'll see him sit in one place and rotate around.

One more thing about Wiggle is that it randomizes based on the layer number of the comp you are in. So if I was to take this gizmo and duplicate him, not only do I have two gizmos, they're each wiggling differently from each other. And you start going crazy and just hit Command+D or Ctrl+D to create a whole swarm of these guys moving around all together, and this creates a lot of fun. That's indeed what we did in the finished composition 05-Wiggle_final. Press Home, RAM Preview. We gave a background, just make life more interesting.

This gives you an idea of how you can quickly create swarming complex animations with a minimum amount of effort on your part. Well, some of you at this point are probably torn. You go, you know this is looking like a lot of fun, but it does require me to type in code, and it does require me to remember how the wiggle expressions has formed. Well, in this case you have a way of cheating. Sometimes cheating is good. I will turn off the expressions, and then I go over to the Effects & Presets panel, twirl open the Animation Presets, then twirl open the category know as Behaviors.

I'll go ahead and drag this a little bit wider so you can see these names. Down at the bottom of Behaviors there is a whole set of wiggle presets you can apply to your layer. For example, if you want to wiggle the position, select for layer and then either double-click this or drag it onto your layer, zero to RAM Preview, and now once again, you've got your gizmo wandering around the screen. But this time, rather than having code, you actually have what looks like an effect. We've got a controller effect up top where you get to enter Wiggle Speed and Wiggle Amount, and underneath is the Transform effect that's using to actually perform the movement.

Those who watched the previous After Effects Apprentice lesson on nesting and pre-composing, saw that we love the Transform effect. You can do a lot of stuff with it. You can go on and add Wiggle Rotation on top of that and add that added in as well. There are several other ones, Scaling, Wigglerama, which has a bunch of parameters, et cetera. Now one nice thing about these behaviors is that you do get this user interface where you get to scrub a value interactively, rather than having to retype it down on the Timeline panel, and you get to keyframe it.

Well, in the next movie, I am going to show you how you can add a user interface and to build the keyframe to an expression you write. You don't need to rely on a preset.

Show transcript

This video is part of

Image for After Effects Apprentice 09: Expressions
After Effects Apprentice 09: Expressions

20 video lessons · 10677 viewers

Chris Meyer and Trish Meyer
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.