Create Swinging Banner In After Effects
Toby Pitman on Fri, January 13th 0 comments
Learn how to create a swinging banner, sign (or even Apple's iPad2 smart cover) in After Effects with Toby Pitman.

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.

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.

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

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

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

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

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). sin-cos

We now have the cards at a starting angle of 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)

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.

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.

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.

Related Videos

You must be logged in to comment. Elektron 109 - Cycles Explored
Elektron 109
Related Videos
Related Articles Dream It. Do It.
Do you want to learn Elektron 109 - Cycles Explored?
Yes, I want to learn!
No Thanks, I just want to read the article.
Feedback 