X Course Advisor FREE Course Advisor
Watch Tutorials
Create Swinging Banner In After Effects

I’ve seen an effect recently in a few different places that simulates a series of connected cards swinging down and coming to a rest in a very natural way. I went about seeing if I could figure out how this was done.

After a few searches on Google I found Dan Ebbert's (the guru of expressions) Pendulum expression. This expression is perfect for this effect as it simulates the exponential decay of a swinging object.  

Step 1

First up I’ve created three Comps made out of an orange solid and a text layer, one for each word.

three comps

I’ve aligned them in my main comp so they’re joining and made them 3D. Notice the anchor point of each comp is aligned to the top of the comps. This is our swing axis. I’ve added a couple of lights, too.

swing axis

Step 2

Now I’m going to parent the layers using the pick whip. Layer 4 (Pro) is parented to Layer 3 (Mac) and Layer 5 (Video) to Layer 4.

Using the pick whip

I’ve done this so the layers stick together even when they are individually rotated on the X axis.

Layers now stick together

Step 3

So now I know that’s working I’m going to add the Pendulum expression to my top (Mac) comp. I do this by Option-clicking the stopwatch for X Rotation.

Option-clicking the stopwatch for X Rotation

Step 5

Here’s the Pendulum expression found on Dan’s site which is full of useful expression goodies.

  • veloc = 7; 
  • amplitude = 90; 
  • decay = .7; 
  • amplitude*Math.sin(veloc*time)/Math.exp(decay*time)

The expression itself is pretty simple. We have three variables:-

  • veloc (velocity) = The initial speed of the swing.
  • amplitude = The angle the initial swing will reach before it starts to decay.
  • decay = This is like resistance. The lower the value the longer the the swing will take to decay. 

And then some math that creates the effect!!

  • amplitude*Math.sin(veloc*time)/Math.exp(decay*time)

While I’m not going to break this down at any length I will show you how it can be manipulated to serve our purpose. I can tell you that the first half....

  • amplitude*Math.sin(veloc*time)

...deals with the movement or swing using a parabolic curve of a sine wave in relation to time which is then divided by....

  • Math.exp(decay*time)

...which uses an exponential curve to decrease the amplitude of the sine wave (or swing).

Step 6

The first thing we need to deal with is the Math.sin part. This determines where the curve of the swing starts. 

Determine the curve swing

Using sin (sine wave) means the swing action will start at the center (0) and move outwards to the amplitude value (90) as seen in this clip. Notice that because the expression is applied to the top Comp in the chain all the parented layers follow this Comp. When I add the final expression to the other layers they will still swing independently.

We don’t want this. We want it to start at the amplitude value and swing in. We can remedy this by changing sin to cos (cosine). 

  • amplitude*Math.cos(veloc*time)/Math.exp(decay*time)

You can see in the image below how cosine starts its curve from the amplitude value (90) and move towards the center (0).



We now have the cards at a starting angle of 90 degrees!

Cards start at 90 degrees

Step 7

Now if you apply the expression to all the Comps X Rotation you can see we are getting a swinging effect on all the Comps.

The only problem here is that the swing is uniform on all the Comps. I want to create something a bit more random and tumbling. So I now need to create a way of offsetting this expression in time. What I’d actually like to do is offset the start of the layers so they don’t all appear at once, but we have a problem.

The time aspect of the expression is running off the master Comp. This means even if I offset the layer the expression will run from Frame 0 (00:00:00:00) regardless. This means when the layer appears the expression will be midway through its cycle.

We can remedy this again by creating another variable. It’s going to look like this:

  • startT = thisLayer.startTime;

This gets the start time of my offset layer and stores it in the variable. I can the subtract this from the first time value in our expression that deals with the start of the curve, our cosine. This will look like this.

  • amplitude*Math.cos(veloc*(time-startT))/Math.exp(decay*time)

I can the subtract this from the first time value in our expression that deals with the start of the curve, our cosine.

Now if I offset the timing of my layer, that offset is subtracted and the expression on that layer thinks the layer starts at Frame 0 (00:00:00:00) or the start of its curve. 

Step 8

So here we can see the offset layer. The Pro layer is visible at this point in time but it’s at a 90-degree angle and hidden behind the Mac layer.

Pro layer is hidden

Here you can see I’ve added the finished expression....

  • veloc = 7; 
  • amplitude = 90; 
  • decay = .7;
  • startT = thisLayer.startTime;

  • amplitude*Math.cos(veloc*(time-startT))/Math.exp(decay*time)

...to all the layers and offset the bottom two layers in time. 

Final expression

The effect is now much more random in how the layers interact together when they swing. here’s the finished demo.

The beauty is that in making the expression more generic in how it deals with the start time of the offset layers it can easily be copied to however many layers you like to produce cascading effects.

You could also easily tie the variable amounts to expression sliders on a control layer to adjust the overall timing of the effect as a whole.

This goes to show that expressions can be used as a very effective tool for simple animations like this which would otherwise take quite a long time to keyframe.

Download the Project File Here.

Toby Pitman

Toby Pitman | Articles by this author

For the past 20 years Toby has worked as a professional guitarist, programmer and producer. Clients include Sir Paul McCartney, George Michael, Shirley Bassey, Yusuf Islam, Giles Martin as well as the London 2012 Olympic Ceremonies. He has also worked extensively in TV, Advertising and Film. As well as composing himself he has also worked alongside many composers like David Arnold, Clint Mansell and Simon Franglen on many major film releases. An expert in synthesis and sound design Toby has also lectured for Apple on their Logic Pro music software which he has used since its days on the Atari. He has also worked as an educator for the International Guitar Foundation and the Brighton Institute of Modern Music teaching guitar. In his spare time (of which there is very little) he moonlights as a motion graphics artist specialising in Cinema 4D and After Effects.


You must be logged in to post a comment.
Create an Account  Login Now

What is macProVideo.com?

macProVideo.com is an online education community featuring Tutorial-Videos & Training for popular Audio & Video Applications including Adobe CS, Logic Studio, Final Cut Studio, and more.
© 2018 macProVideo.com
a division of NonLinear Educating Inc.