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.
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.
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.
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.
Here’s the Pendulum expression found on Dan’s site which is full of useful expression goodies.
The expression itself is pretty simple. We have three variables:-
And then some math that creates the effect!!
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....
...deals with the movement or swing using a parabolic curve of a sine wave in relation to time which is then divided by....
...which uses an exponential curve to decrease the amplitude of the sine wave (or swing).
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).
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!
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:
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.
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.
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....
...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.