Mar 7, 2011

Using Expression Controls

Hey guys!
So here's another AE tip as a follow up to the last expressions post. This one is concerning the Expression Controls found in the Effects menu.

Click the title for the full post.

What are Expression Controls?
Expression controls are empty controls that can be used to control properties via expressions, so the name pretty much explains it all.
The expression controls are:
1. Checkbox
2. Angle
3. Color
4. Layer
5. Slider

I'm sure you can find out which is which...

So, they're all set up, how do we use them?
You can use expression controls to control multiple layers, saving time on editing each parameter separately, and also (and especially) use them to set up cool animations. In an example, we're going to use the Angle Control.

Create a new comp (I usually do 720 x480 Square Pixels 30fps, 15 seconds) and we're gonna create some text. So just type out something.
Set it in the middle of the screen (Ctrl+Home btw puts the anchorPoint in the center) and now we can create some cool controls.

Create a new Null object and call it "Controller", this is what will house out controls, and I'll explain why in a bit. Go Effect > Expression Control > Angle Control

Okay, the scene is set, the control is all set, now we need to apply an expression.
Head over to the text layer and press R to bring up the Rotation.
Now, before you Alt+Click, you'll notice that you can't see the control in the effects panel from the Null, so we can't immediately pick whip it. If you're feeling brave, you could try type out the full reference path-thing, otherwise, I'll show you two ways of showing this control:

1. Press E while the Null is selected to show its effects in the timeline
2. Click on the LOCK in the top-left of the Effects panel:

All right.
Now we can go into the text layer's rotation and Alt+Click on the stopwatch. In the expression box, let's pick whip the Angle Control's ANGLE.
Now, this is pretty simple, coz what we get now is:

thisComp.layer("Null 1").effect("Angle Control")("Angle")

Pretty straightforward. But let's make this a bit more interesting.

What happens if I was to duplicate this layer and play with the Angle Control? Both layers would move to that angle.
Now, what if I wanted the layers to move in increments? Like have layer 1 at 10 degrees while layer 2 is at 20 degrees...?

I'm going to take this opportunity to introduce you to the expression value: INDEX.

Index refers to the layer's vertical position in the timeline. In the case below:

Null 1 has an index of 1, the text has an index of 2.

Do you see what we're about to do?
If we want layer 1 and layer 2 to be incremental, how about we just multiply the above expression by the index?? 

thisComp.layer("Null 1").effect("Angle Control")("Angle")*index

There we go. So if our angle control was set to 15, layer 1 would have 15 rotation, layer 2 30, layer 3 45.
But there's a flaw here, out Null is layer 1, so we're going to start at a rotation of 30 (15* index of 2)
In order to fix this, just add a minus 2 (so that the first layer is multiplied by zero)::

thisComp.layer("Null 1").effect("Angle Control")("Angle")*(index-2)

To keep things neat, we can turn the Angle Control reference to a variable, so our expression should be:

turner = thisComp.layer("Null 1").effect("Angle Control")("Angle");

Now try duplicating the layer a bunch of times... I made 4 copies::

My value was set at 5, so the bottom-most layer has an offset of 20 degrees. Try going into the Angle Control and applying wiggle(.5,10)
(I also added a 2 pixel stroke and a drop shadow effect so we can simulate depth).

Speaking of simulating depth, why don't we just CREATE depth??

We've created some nice rotational displacement, how about we create some Z displacement.
Head over to the Null and create a new Slider Control. When it's created, press ENTER and name this "Z offset", you can rename the top one to "Rotator" (the expression will automatically update).

Also, let's delete the duplicates and leave one, then make that one 3D (otherwise we can't do Z displacement).

Now, we can head over to the Position property of the Text layer, and we're gonna type a special expression here:

offsetter=thisComp.layer("Null 1").effect("Z offset")("Slider")*(index-2);
value + [0,0,offsetter]

Wait a second, what the heck is that in the brackets?
Calm down, I explained arrays in my earlier post here.
An array (for those too impatient to go to the post) is like how we'll tell the expression to add the offsetter value ONLY to the Z. So in the above array, we take the value (which in my case would be [360,240,0] literally), and add [0,0,offsetter], and we've designated offsetter as the Z offset slider, working with INDEX the same was as our rotator.

So having done all that, we should be good to go. So, go ahead and set the slider's value to 10 and our rotator value to 0. Create a camera and make the duplicates and....

Super happy fun times!
Try out keyframing and wiggling while we're here!

Okay, so what else can you add?
Well, pretty much anything! You can add this to opacity and pretty much any other control you want. You can also add color control for the layers, point control for what position they'll be at.

Want to take this further??
Create an Elegant Concentric Rings Animation by Satya Meka on AEtuts covers some interesting expressions using index and valueAtTime.

3D Offset on Video Copilot uses sliders and index to create some pretty cool effects.

Enjoy, guys! Send me a link of what you've made!

No comments :

Post a Comment