top of page
Search
Writer's pictureChris Kenward

Quick Tip: Looping Wiggle Expression


I’m going to pre-empt this post with a disclaimer; I drank a hell of a lot of coffee before writing this one, resulting in a fair amount of hyper-caffeinated waffle. Skip straight to "THE EXPRESSION" to copy the expression which, lets face it, is what you came here for.


Oh, double disclaimer, I did not write the expression that I’m discussing in this article. I found it on AE Reference.com, which is a fantastic resource well worth bookmarking. The expression itself is accredited to Dan Ebberts, so go give him some love as well!


It’s 10am, you’re working Hard on a project with a slowly looming deadline, you’re on top of things but you’re aware of the ever-malleable nature of client work and that the rug can be pulled at any moment.


Bang, in marches Head of Post. ‘We need to turn around a quick, infinitely looping gif with plenty of natural looking camera shake for *insert name of high profile, high paying, overbearing client here* by the end of the day. The rest of the team is busy so it’s down to you to knock this one out asap.’ Rug, monumentally pulled.


If you chose to stick with my arguably superfluous preamble, then you may well be somewhat familiar with the above scenario; this is after all a semi-common occurrence in big production houses (especially those with retainer clients).


Let’s take it for granted that you already have all the assets, brand guidelines and client understanding locked down, but what about that pesky camera shake?


Okay, you may be thinking, that’s easy, I’ll apply a wiggle expression to the position properties of a 3D camera, job done. Great, until the playhead reaches the end of your timeline and you realise that your beginning and end frames no longer match up.


Crap, you may be thinking, I’m going to have to keyframe these values manually. Of course, this would work but you know from feverish glances at the office clock that time is of the essence.


The solution? An ingenious and very fancy bit of code written by Dan Ebberts that loops the wiggle expression infinitely. It even allows you to change the duration of the loop. Game, changed.


THE EXPRESSION


frequency = 2; // wiggles per second amplitude = 40; // amount of pixels to wiggle secondsToLoop = 3; // time to loop in seconds // -------- t = time % secondsToLoop; wiggle1 = wiggle(frequency, amplitude, 1, 0.5, t); wiggle2 = wiggle(frequency, amplitude, 1, 0.5, t - secondsToLoop); linear(t, 0, secondsToLoop, wiggle1, wiggle2)


To put the above to use simply copy it, alt click the stopwatch of the value you wish to loop and paste in the expression. If you’re new to expressions I’m sure this might look a bit daunting but there are only three values you really need to concern yourself with to get this working for you.


frequency As with the standard wiggle expression frequency determines the amount of ‘wiggles’ per second (a hilarious statement I know). In layman’s, changing this value will increase or decrease the speed at which the wiggle occurs, making your action appear faster or slower.


amplitude Also in tandem with the standard wiggle expression, amplitude delineates the amount of pixels you want the wiggle to affect. Come again? Put crudely, this value will adjust how large or noticeable the wiggle will be. Using camera shake as an example, a large value will cause the camera to fly around all over the place, a small value will cause small judders.


secondsToLoop This is where the expression flourishes. Simply type the amount of seconds you want the wiggle to last before looping back to it’s starting point. If you have a five second loop, simply type 5 and marvel at the spectacle of a wiggle animation looping like clockwork.


Now its down to you, copy the above, apply it to a property and have a play around with the values until you find an outcome you like. To give you a head start the below generates a fairly frenetic camera shake lasting five seconds before looping back to its starting point:


frequency = 4; // wiggles per second

amplitude =20; // amount of pixels to wiggle

secondsToLoop = 5; // time to loop in seconds

// --------

t = time % secondsToLoop;

wiggle1 = wiggle(frequency, amplitude, 1, 0.5, t);

wiggle2 = wiggle(frequency, amplitude, 1, 0.5, t - secondsToLoop);

linear(t, 0, secondsToLoop, wiggle1, wiggle2)


And there you have it, a looping wiggle expression to bail you out when burnout is encroaching. Thanks for reading and as always, I hope this helped your workflow.


Now for some links: AE Reference.com

4 views0 comments

Comments


bottom of page