5 Amazing Expressions in After Effects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey what's up this is Caleb with school of motion and in this After Effects tutorial I'm going to show you five unique ways to use expressions in After Effects now this tutorial is going to cover some different ways in which you can use expressions that you may not have used in the past so if you're ready to learn something new let's hop in now this tutorial is all about unique ways to use expressions this is an expressions 101 if you want to learn how to use expressions on a more fundamental and basic level go check out our expressions 101 tutorial so let's kind of hop into our first example here so you may be familiar with the loop expression in fact we put together a tutorial a couple months ago that was all about how to use the loop expression in After Effects and the loop expression is fantastic because it can do so many different things but the loop expression that really stuck out to me was the offset loop and just a quick refresher if you don't remember what the offset loop does basically if you kind of envision this triangle moving here let's say it moves from here to here over the course of a second if you use a loop offset it will basically take that data and add it to the end of your animation so that it will continue along that path and that's exactly what we're gonna do here so I'm gonna go down here and I'm gonna set a keyframe for let's say the 12 frame mark and actually let me take this time to say that you can actually go download the project files for this tutorial over at school emotions so you can follow along and kind of set the keyframes with me I find that I learn a lot better that way so you know you can go do that over at school of motion there should be a link in the description of this video so let's say that we want this triangle to move across the screen so I'm gonna set a keyframe at the 12th frame mark and then I'm gonna move forward to let's just like pick a random spot here let's pick the two second mark and then we'll kind of pull this up here to like right about there and you know if we play this back like obviously the triangle is just gonna like come to rest right there but if we hold down option and hit the stopwatch right there we can type in loop out open parenthesis and then quotation marks and we'll say offset quotation marks in parentheses and semicolon so so now if we kind of script through here you can see that triangle just kind of continues along the same path but here's the cool thing because we use the loop offset we can actually manipulate these keyframe values here to change the speed in which the triangle goes across the page so check this out so now it's going a little bit faster because the keyframe was moved closer to the first keyframe so now it's gonna go really quickly across the screen this is a really cool technique because traditionally if you wanted to manipulate something over the course of time you would think that you want to use the time expression and the time expression honestly is kind of lacking whereas this expression allows you to change values very easily if you wanted to adjust a time expression you'd have to basically go down here into the expression editor and type in you know time and you'd have to change it from let's say 40 to like you know 55 and then you'd have to like go out of the expression editor and you just have to go back and forth if you wanted to change the speed but by using this technique where you actually can manipulate these keyframes it basically gives you a slider in a visual representation of the speed so now we can play this back and we can see the triangle kind of moves along at the kind of correct speed for our composition so let's hop over to our next example here so the index expression is one that you may or may not be familiar with but but let me explain this I think more on a fundamental level here so in the After Effects timeline there are different layers right and your layers have a specific number associated with the order in which they are placed in the timeline so for example this little number right here says one next to the shape number that is an index number of one for that layer and below that it has an index number of two and below that that layer has an index number three and so on and so forth so as you can tell if we were to manipulate that number in some way we could actually tie our freshens to an index number so let me kind of give you an example of something that we could do here so right here we have a simple triangle this you know first layer right here has an index number of one and we have a triangle with three points but let's say for each additional layer that we wanted to add to this composition we wanted it to go from a triangle to a square and then to a Pentagon and we wanted to basically add a side for each layer that was created now what you can do is hold down option and click the points here and all we have to do is type in index plus two and then semicolon so all this is saying is whatever layer number this is add two and so because this is the first layer you're gonna get three sides and voila it's a triangle nothing happened so if we duplicate this now you can see that boom there's a square and a Pentagon and a hexagon and we could just keep on doing this forever and ever but you know we can actually take this one step further so the anchor point for our shape is right here so let's say we wanted it to rotate every single time we created a new shape so all you have to do is hit R for rotation and you know we can rotate this triangle however you want but let's say we want the triangle to start right here all you have to do is hold down option and hit the little stopwatch right here and what we can say is index times let's say 60 so what this is saying is you know the number that the layer is in the order in the composition so this is number one multiply that by 60 so it's gonna rotate 60 degrees but I'm gonna go ahead and put minus 60 so that for our shape layer here we have our index which is 1 times 60 which is 60 minus 60 which is 0 but if we duplicate that and have layer 2 it's going to be 2 times 60 which is 120 minus 60 which is 60 and so it basically is going to increment and add 60 points of rotation to each shape as they're duplicated so now we can go in and hit command D for duplicate and we are gonna create more shapes that are gonna kind of go around this circle here so that's the index expression I use this expression all the dang time and there's just so many different examples of ways in which you can use the index to help you out in your After Effects projects so let's move on to our next expression so now let's talk about the linear expressions so the linear expression is one of those things that like once you find out about it you like hit yourself in the head cuz you're like oh my gosh I could have used this on so many projects in the past but it's really one of these things that's kind of easy to understand it's just for whatever reason a lot of people don't use it so let's explain kind of what it does here so basically the linear expression converts a certain range of values into another range of values and and that sounds kind of confusing but let's think about it like this so let's say that we had a shape that scaled up from 5 to 20 but we wanted to have a slider that could be controlled from 0 to 100 where 0 could be the 5 and 100 could be the 20 now to do that you can use a linear expression and a linear expression will basically do all of the math between all those steps so that when you adjust your slider the shape is only going to go between 5 and 20 now let me show you a little practical example of how to use it so in this timeline we have a sound effect and then we have this triangle right here I'm gonna go ahead and play this back so you can kind of hear the sound effect all right you get the idea it's like computer bleeps and what I'm gonna do is use a really cool tool if you right-click on the sound effect just go over to keyframe assistant and convert audio to keyframes and that is actually going to create a null object and if you hit you you can see all of the new keyframes that have been created here and this is basically going to take the waveforms and create numbered values for the waveform so if we kind of scrub through here you can see that the value of all of our audio channels is being adjusted here now nothing is happening these are just kind of placeholder values for the audio waveform data this isn't actually doing anything you know you can see the null object is staying still but let's say that we wanted to attach our triangle position here to where it kind of Bob's up and down with the data from these sliders here to do that all you have to do is select the triangle and go ahead and hit P and we have X position and Y position and if you can't see that just go ahead and hit right click and you can do click separate dimensions we're just going to manipulate it along the y axis here so what we're gonna do is hold down option and hit the Y position and we're gonna type in linear open parenthesis and then we are going to pick whip you know use this little squiggly line here we're gonna pick whip to both channels to this both channels slider here and we're going to type in comma and now we have to pick the low value so the low value for our sound effect here is about three so if we kind of scrub through here so you can see that the low value is 3.14 which is pi that's kinda neat so we'll type in 3 and then we'll do comma and then we'll pick our high value value so let's scrub through here and just see what the highest value that it goes up to is and it looks like 26 is about the highest value that it goes to so I'll type in 26 right here and then we're going to type in comma and now we can set the value of the position of this triangle so the first two values are referencing this input value right here which is the both channels so any number between 3 and 26 will be mapped now to these next two numbers so so for the low number we'll say that the value is 654 I think that's a good number so for the high number you can actually do numbers that are lower than the first number so even though our value is going from 3 to 26 we can do 654 to let's say 200 put an in parenthesis in a semicolon and click away and now our triangle is actually going to bounce around between those two points between 200 if the value is 26 and 654 if the value is 3 and everywhere in between so we can just play this back here you can see it kind of bounces around another cool expression besides the linear expression I'll just do this real quick is the ease expression if you just type in ease this is works in a very similar way as the linear expression it just kind of eases some of the values and makes it a little a little bit softer you can see it kind of smoothes out a little bit lower towards the bottom there so it's a really great expression that I use all the time especially when creating templates or essential graphics panel templates to throw over to Premiere Pro it's it's fantastic and I'm sure that you'll find many many uses for it in the future so let's move on to our fourth expression so the fourth expression that we're talking about here is the clamp expression and the clamp expression is so dang useful in After Effects but a lot of people just don't really know about it and don't really use it all that much but basically the clamp expression sets parameters and basically says you cannot go beyond this low value and you cannot go above this high value and it basically says you have to stay within two parameters and that's super helpful if you create templates let's say central graphics templates for editors to use or if you work in the team environment and you want to pass stuff off to someone else you're a little unsure about their design skills and you want to just make sure that you know they are staying within the parameters of your brand you know for example so let me show you how to use it it's super easy all you have to do I'm going to go to layer new adjustment layer and I'm gonna go to the effects and presets browser and type in slider and I'm gonna drop a slider control on to the adjustment layer and by default the value is only from 0 to 100 I'm actually going to right click up here in the top part and go to edit value and I'm gonna change the end value to 2000 and hit OK and now you know we can drag the slider between 0 and 2000 awesome but nothing really happens right so go ahead and select the square and hit P for position and make sure you have your value separated and again if you don't have your value separated you can right click and just go to separate dimensions so I'm gonna attach the exposition to the slider control in our adjustment layer here and in fact I'm gonna hit this little lock icon at the top so that it locks the effects layers or the effects controls of the adjustment layer so that when I click on the square it stays with the layers effects controls you can see up here so I'm gonna hold down option and hit the X position here and I'm gonna type in clamp open parenthesis and now we have to pick the value that is going to be clamped and I'm going to drop it on to the slider control there and now I'm just gonna hit comma and now we're gonna add in our minimum value so the minimum value for this slider is 852 and the maximum value is 1700 and infancy in parentheses and semicolon so now if we drag our slider here you can see that nothing happens nothing happens but when we go past 800 it moves and then it stops it's 700 and doesn't go any further now there's so many different useful ways in which you could use this you know one example would be let's go ahead and let's say we duplicate this layer and I'm just gonna pick whip this new square right there and then I'm gonna move the anchor point down a little bit you know let's say you had a shape animation but you wanted this top shape to to you know only be bound in this box right here well you could use the clamp expression and now you know the original square comes through and now they move together and then they stop you know it's just you know super useful and there's so many different ways in which you could use it in a project really the sky's the limit so let's go to our last expression here so our final expression and that we're gonna learn how to use here is the value at time expression and again this is so dang helpful if you do a lot of After Effects work so I'm gonna like create a scenario here for you so I'm gonna play this back you see we have this triangle here it kind of spins in a circle and it scales down and goes away so let's say that you wanted to offset that triangle by half a second what would you do now typically what you do is you know you'd say oh well I'd let's say you know I duplicate the triangle and then I'd move the duplicate over about a half a second where it's you know it pops up and then another one pops up and then they animate off but what if you wanted to do that in ninety times that would take a lot of time right like you have to duplicate offset duplicate offset or you would have to find a script that could do that or or you could use the value at time X rushon so this is a helpful expression that will basically take as the name implies a value at a specific time and you can take that value from another layer so for example we can have the set up where any duplicated triangle is taking the value of this triangle at a half a second step backwards in time so that'll make a little more sense in just a second so let's go ahead and I'm gonna go ahead and duplicate this triangle right here to where we have triangle one on top and triangle two on the bottom and I'm going to hit you you so I can see all of the layers that have been manipulated in this specific layer and I'm going to go ahead and hit you for the outer radius here of triangle number two so basically what we have going on just so I can break this down is we have a shape layer that has a poly star and then a poly star path that has three points and a three-pointed star is just a triangle it aftereffects doesn't have a triangle shape it just uses you know points like it's the starship anyways so it's a three-sided polygon with an outer radius of 68 whatever it is at full size and then zero you know before it animates on that makes sense right and then we also have rotation that basically makes the the triangle spin in a full circle over the course of about what's that like three seconds so what we're gonna do is add a little expression to both the outer radius and the rotation of our second triangle here so I'm gonna hold down option and I'm going to go ahead and pick whip to the outer radius here so we'll do the outer radius of the first triangle and I'm gonna go in here and add an expression so I'm going to hit period and we're gonna do value at time open parentheses we're going to do time minus 0.5 in parentheses and semicolon so let's explain what's going on here so this is basically saying this complaints are the poly star so the of the polystar more specifically the poly star path one which is our triangle specifically and we are going to take the value of the outer radius and we are going to take the value of that outer radius at a specific time and we want that time to be in sync with regular time so we want the you could put one and it would basically take the value at one second and it would just be basically still or you can take the value at time and it will basically just keep the same value in sync and then we can put minus 0.5 which will offset it by about a half a second so as it moves it's going to be a half a second lagging so I actually want to change this part right here so this is basically saying to use the value from the triangle you know triangle layer so the very first shape layer in our time line but instead I want this triangle in any derivative triangles to take the value of the previous triangle so if you think about it if we have a triangle that pops up and offsets we want another one to pop up and offset but then we want the next one to pop up an offset in relation to the second triangle and not in relation to the first one because if if all of them are offset by a half a second from the very first one then basically we're just going to have a bunch of triangles stacked up on top of each other and there's not going to be that cool offset effect so in order to do that I'm going to type in index which you know is the value of the the shape layer position in the timeline we already talked about index earlier and I'm going to do index minus one so this is basically this a whatever this number is right here subtract one so it's going to take its value from this top triangle right here I hope I didn't lose you I hope that made sense so I'm gonna go ahead and click away here and if we go ahead and play this back let me go ahead and make this big here so if we go ahead and play this back you can see that that pops up and then another triangle pops up but the rotation is not offset so now that the scale is at a half second lag I'm gonna hold down option and hit the rotation here and going to do the same thing so we're gonna go ahead and pick whip to the rotation of the first triangle layer there and instead of triangle we're gonna do index minus one and then we are going to hit period and we're gonna do value at time open parenthesis and we're gonna do time minus point five in parentheses and semicolon so now we click away we can play this back and see that we have to offset shape layers now the cool thing is because we set this up correctly you can literally duplicate this as many times as you want and there will be more offset shapes so I can see it's like a never-ending array of triangles and again this is super helpful especially if you're working with you know hundreds of layers in After Effects instead of just six so I hope that you found this tutorial to be helpful if you want to learn more about using any of these expressions in After Effects and go check out the blog post over at school of motion it has a lot more detail about using each one of these expressions individually and of course you can go download the project file that was created for this tutorial over at the blog post there's a link in the description of this video and you know while you're over at school motion go check out some of the other stuff that we have we have a great podcast it talks about the motion design industry we have many many other tutorials and blog posts and then of course the school of motion boot camps which are the best way to up your motion design skills so again this has been Caleb Ward and we'll see you on the next tutorial
Info
Channel: School of Motion
Views: 432,130
Rating: 4.9631352 out of 5
Keywords: motion graphics, tutorial, After Effects, Tutorial, Expressions, Offset, ValueAtTime, Linear, Clamp, MoGraph, School of Motion
Id: vQzVmae72wM
Channel Id: undefined
Length: 22min 7sec (1327 seconds)
Published: Tue Oct 10 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.