Adobe After Effects is a wonderful application,
but sometimes it takes so much time to create a simple animation.
So there is where cheat codes come in, or in other words,
expressions.
Now, let me know in the comments guys, if you could actually cheat in After Effects,
what would you do?
Like, I would enable God mode so that After Effects would never crash again.
I'm gonna give a copy of my Adobe After Effects course to the most creative comment,
so go nuts in the comment section down below, guys.
Now with every property of Adobe After Effects there's a stopwatch,
which allows you to create animations.
But when you hold down your alt key and then click on the stopwatch, an input field will open up.
Right in here we can enter some codes,
like the most famous wiggle,
which will then automatically animate that position property and let your elements randomly wiggle.
But there's so much more out there than the wiggle expression.
So without further ado, let's have a look at five very simple expressions
that will save you so much time.
Say you create an animation like this and you want it to loop,
instead of copying and pasting the keyframes,
simply alt + click on the stopwatch and type loop-out
with an open and closing parenthesis.
And badabim-badaboom, your animation loops itself forever.
You can always change your keyframes afterwards to make the animation go faster or slower.
Now, with loop-out we're seeing to loop the animation after your last keyframe,
but you could also use loop in, which will repeat the animation until it reaches your animation keyframe
and then stop.
Next up is beam-linking.
We're not gonna write any expressions this time,
but we will use the property link feature.
Say that you've got two or more objects that we have a certain animation on.
Now, let's add a wiggle expression to all of them for the position property.
Next, create a new solid layer
and search for the beam effect in your effects library,
which you want to apply to that solid.
You can further customize the way that you want your line or beam to look,
but one thing is important and that is the length which needs to be set to 100.
And from your layers, expand the properties and locates the starting and ending points.
Use the pickwhip on the right to connect it to the position property of one of the graphic elements.
The ending point goes to the position property of the other element.
Now basically an expression is automatically written, which simply says
take the value from the circle element.
That's it.
And that's how you can connect two elements to each other.
The line in between will always follow.
Now, if you see something like this, it means that your Anchor Point is not in the right place.
So make sure to drag it to the middle of your element for holding down your ctrl key,
or command key for the Mac users.
Now here's another awesome expression.
Hold down control + shift + D + M + L
and then double click in your timeline.
This will fire up Storyblocks Video, our channel sponsor.
Storyblocks is an online library packed with stunning 4k stock clips in various styles and categories.
There are overlay effects, graphics, and even After Effects templates.
You can simply choose something like a logo reveal, a lower-third animation,
an intro sequence and then change it with your logo with a press of a buttom.
Now, we use Storyblocks ourselves with almost every project,
because it saves us time and very often we wouldn't even be able to create something similar.
There's only a single super cheap price per year allowing you to download unlimited video assets.
So definitely worth checking out, which you can do by clicking the first link in the description down below.
Now let's press ctrl/command,
shift, Apple and Windows key at the same time to go back to After Effects.
The next expression that I'd like to cover is time.
For instance, you open the expression box for the rotation of an element,
simply type time, which gives the value of the current time in your composition to the rotation.
Now since time is in seconds, your element has only rotated one degree after one second,
so you might want to add a multiplier to it,
for instance multiply by five hundred.
And this way your element keeps spinning around forever as you play your timeline.
Now, of course I'm just scratching the surface here by showing you these expressions.
When cleverly used, you can create some really dope animations using something really simple like this.
Next up is the if-else expression.
This means if you do something,
change this.
If you don't, then change something else.
So basically you can use this for so many different applications.
Here's a little traffic light with two circles in them.
One is red and one is green.
Here, we have another layer, which is a car.
Now, let's alt + click on the opacity property of the green lights and start typing if.
Open parentheses,
I'm gonna take the picwhip tool and select the x-position of the car layer.
Then type the greater than icon,
followed with approximately the current position of the car,
which is a thousand two hundred in the exposition.
And then close parentheses.
So what we have now is if the position of the car is gonna be greater than
1200, do the following.
And that following will be, open bracket,
zero, and close the bracket again.
The zero is the final output,
so in this case the value of the opacity.
After this we can also add else,
open bracket,
100,
close bracket.
So if the position value is not greater than 1200,
then the opacity can be 100.
Now, let's see what it does,
I'm going to click and drag around the car in my composition,
but whenever it comes too close to the traffic light,
the green light goes off.
So if we type the exact same expression in for the red light,
but change the greater than character to smaller than,
we'll have the lights always turn red
whenever a car approaches.
Just like in reality.
And that brings me to the last expression, which is random.
Let's create a text layer, but leave it empty.
On the source text property, alt + click on the stopwatch and just type in random.
Then between two parentheses,
you can define two numbers.
This way After Effects is gonna generate a random number
between those two values.
And here's a little extra tip, if you type in math
dot round,
and then that same random expression between two parentheses,
you get a random number without the stuff behind the dot.
Now, it's gonna generate a number every frame.
If you don't like that, before the random expression
type seedRandom,
open parentheses,
index, which refers to the random expression that we've just typed in,
then comma,
true,
which means timeless is true.
Close parentheses.
And this is gonna say to only generate one random number.
So now that we know how it all works, let's apply it somewhere useful.
I've got a bunch of circles and I'd want them to have a random size.
So I'm gonna go to the scale property and first type the seedRandom expression
with index referring to the random function that we're about to type
and timeless set to true.
Then random, and I'm gonna choose between scale 20 and 100.
Unfortunately, this is gonna give us an error
and that is because we are generating just one random number,
but scale actually needs two numbers.
There's a scale height and scale width.
So I'm going to store the random number and a letter.
And you can choose whatever you want,
let's take the letter A followed by equals.
Next open a bracket and type A,
comma,
A.
Close bracket.
This is the way of giving a two dimension property a value.
Now because we've been typing some advanced stuff,
we're gonna have to add a semicolon every time on the end of every line.
So if you're experimenting with expressions and you ever see an error, just try and do that.
Might fix your problem.
We can now go ahead and copy the scale property,
which holds the expression, and paste it to all the other circle elements.
And badaboom bim bam bom, look at that!
And of course, there are thousands of more possibilities for generating a random value.
Now, it might sometimes feel like writing expressions might take longer
than if you would actually make your animation manually,
but if you get just used to it and take the time to learn how to code,
then it's actually gonna save you a lot of time in the long run.
So, definitely small expressions like these are easy to remember
and if you understand how they work
you can more easily adapt them to something specific that you want to accomplish.
Alright, thank you so much for watching guys.
Thank you Storyblocks for the support.
Go check them out right now, and as always...
Stay creative!
Guys think about this,
a cheat code
that if you would enable it
and you export your final work out of Adobe After Effects and send it over to your clients,
your clients will actually reply within the first day saying
"I love it, I'm gonna pay your invoice right now.
I don't want any changes."
Nah.