Advanced Squash and Stretch in After Effects

Hey, this is Jake Bartlett for School of Motion
and in this lesson I’m going to be teaching you about an advanced squash and stretch method. Now if you’re not familiar with the squash
and stretch animation principle, you should definitely go back and watch Joey’s lesson
on what it is, why it’s important, and how to do it. That’ll get you up to speed, then you can
come back to this lesson and learn how to apply it in a more advanced way. Squash and stretch can add a whole lot of
life to your animations and it’s really great for making things look cartoony. Now what we’re going to do in this lesson
is streamline the entire process of applying squash and stretch to anything you wanna animate. Simple shapes, text, characters, anything
at all. And on top of that, we’re gonna be adding
an extra level of detail that will create unique deformations with your squash and stretch. We’re gonna be using a few expressions, but
none of them are too complicated, so don’t worry if you’re not too savvy with them. And don’t forget to sign up for a free School
of Motion student account, so that you can have access to my project files for this lesson
as well as all the other lessons on School of Motion. Plus, you’ll be added to our weekly newsletter,
which keeps you up-to-date on this industry and everything that’s happening over here
at School of Motion. Now squash and stretch is a super helpful
technique for giving life to your animations, but sometimes just using the Scale property
makes it all look a little too uniform and can start to look a little plain. Let me show you what I mean by that. I’ve set up this little demo to explain what
squash and stretch is and then what we’ll be doing. So on the left side you see there’s no warping
at all. This little chiclet guy is just jumping up,
falling down, there’s no squash and stretch. In the middle here, I’m using the Scale property
to drive the squash and stretch. So the character anticipates his jump, squishes
down, hops up in the air, and then deforms to make a much more cartoony, bouncy, squishy
looking animation. That gets the job done and a lot of times,
it can look just fine. But what we’re about to do is add another
level of detail that you can see over on this third character, where we’re not only scaling
the layer, but we’re also deforming the shape. So right in here, you can see that the character
is bending in a way that just animating the Scale property wouldn’t allow us to do. That little extra detail can add a lot of
life to your animations. So let’s jump in and see how we can make this
happen. I’m gonna make a new comp. 1920 by 1080, 24 frames per second. And I’ll make the background white so it’s
easy to see. And I’ll start by making a new solid and I’ll
just make it 200 by 200 pixels, and pick a nice orange color. Hit OK. And then I’m going to add the Warp effect. So I will find Warp and apply it. So let’s take a look at what this effect is
doing. You may be familiar with it already, but it
just allows you to bend and distort whatever it’s applied to in some preset ways. So by default it’s set to the Arc Warp Style,
and I have this Bend control, which allows me to control how much it bends and in what
direction. I can also choose which axis to warp it on,
so we can go vertical or horizontal. And if you go through the warp styles, there
are all different kinds of warps that you can apply to your layers. So you can take some time to look through
all of these. We’re gonna be using the Bulge warp style
for this. And as you can see, this warps the top and
bottom when it’s set to Horizontal. And if I change it to Vertical, it’ll kinda
push the edges out or bring them in. This is how we’re going to be using it, so
make sure the Warp Style is set to Bulge, and your Warp Axis is set to Vertical. Some other controls we have are Horizontal
Distortion and Vertical Distortion, and these are also gonna come into play. If I adjust this, you can see that it kind
of skews the layer left and right, or up and down. Now one important thing to take note of is
that right now this Warp effect is basing the warp on the size of the layer. But if I were to make a Shape layer, and I’ll
make the square the same size as our Solid, and I’ll just push it over to the side so
we can see it, and then I apply the Warp effect to that, you can see this is not working the
same way. If I move my Shape layer around, it doesn’t
really seem to make sense at all. What’s actually happening is that because
this is a vector layer and not a raster layer like the Solid, the effect is being based
on the bounding box of the comp rather than the bounding box of the layer. And that’s how it’s going to work for any
layer that’s vector or continuously rasterized. So Shape layers, Text layers, and continuously
rasterized comps. The workaround for these types of layers is
to precomp the artwork before you apply the effect. So if you’re gonna be using Shape layers or
text, anything that the warp isn’t based around the bounding box of the layer, make sure that
it’s precomposed. So if I remove the effects and precompose
this layer, name it Box, this precomp is still the same size as my main comp, so I need to
go into it and change the size to be 200 by 200. Now I could leave a little bit of room around
the outside edges if I wanted and that would be just fine. So let’s say 250. And that might give you a little bit more
room to customize this if you were turning it into a character like my example. But then we come back out to our main comp. I’ll copy this effect onto the box. Now it works exactly how it needs to. Alright, I’m gonna delete that layer and we
can move on. The first thing I wanna do is link this Vertical
Distortion to the Bend amount so that those two numbers are always the same and I only
have to animate one of them to get the result of both of them. So I’m just gonna open up the effect and then
I’ll add an expression on the Vertical Distortion by holding Option and clicking on the Stopwatch,
and then pick-whipping the Bend value. That will automatically generate the expression
code that it needs to reference that effect. I’ll click off of it and now whatever this
value is set to, the Vertical Distortion value will update with it. So already we’re simplifying our process by
cutting out one of the properties that we would’ve had to keyframe by hand. I’m gonna set this to zero for now. And we could drive the squash and stretch
part of this effect using the Scale property. So I could open up the Scale, unlink them,
set this one to 50 and this one to 150, but that squash and stretch is based on the anchor
point, and I would want it to be at the base of the layer. So if I move that down to the base, that could
work, but now my anchor point is at the base of the layer so things like the rotation are
gonna be based on that as well. So instead of using the Scale property, we’re
gonna use an effect that’s gonna make the squash and stretch completely separate from
the Transform controls of the layer. So we’ll come over to the Effects & Presets
and type in transform and apply the Transform effect. Now if you’ve never used this effect before,
it basically just gives you all of the transform properties that any layer already has, as
well as some additional controls that are gonna help us out with this rig. So here I’ve got a scale. I can reposition the layer. And you’ll notice that the actual layer itself
is not moving, it’s just the contents within it. So this added level of control is really gonna
help making animation a lot more controlled and fine tuned. So let me recenter that. The first thing I wanna do is be able to change
the anchor point. So if I grab the anchor point and adjust it,
you see that’s shifting my layer around. To fix that, I need the position to go where
the anchor point is and then the layer will scale off of that point. But I want that to automatically happen wherever
I put the anchor point the position to go with it. So we’re gonna add another expression. I’ll press E to bring up my effects, twirl
down Transform, and I just wanna link Position to the anchor point. The same way we linked Vertical Distortion
to the Bend. So I’ll hold down Option, click on the Stopwatch
for Position, and then use the Expression pick-whip to select the anchor point. Let go, click off. And now wherever I put this anchor point the
position moves with it. Now my layer is still moving because I changed
the Scale. So let me put that back at 100. But here we go. Now I can move this anchor point around and
the layer stays where it should. So I will just drop this down to the bottom
center. And then I wanna unlink my scale, width and
height. So I will uncheck this Uniform Scale. So now I can independently adjust the height
and the width. And that will allow me to animate my squash
and stretch. Now these are two separate properties, but
I don’t wanna have to keyframe both of them to drive my squash and stretch. So if you remember from Joey’s lesson, you
want your layer to pretty much maintain the same volume at all times. So if you were to scale the height down to
50, you would want the width to scale up to 150. And the way you can always check this math
is just add up these two values and make sure they always equal 200. So if this is 125, then this should be 75,
that equals 200, the volume is maintained. But when you’re animating, you don’t wanna
have to think about all that math, and frankly you shouldn’t have to. So we’re gonna solve this with expressions
so that After Effects does the math for us and these two values always equal 200. To do that, I’m just gonna Option-click on
the Scale Width property, and I’m gonna type in 200 minus, and then I will pick-whip the
Scale Height. So this value should be 200 minus whatever
this is set to. If I click off of that, that simple little
equation is now calculating my squash and stretch for me, so all I have to do is animate
the Scale Height and the volume of that layer will always be contained. So very simple little equation, but it completely
simplifies the process of animating squash and stretch. And just to reiterate what this anchor point
is doing. If I clicked and dragged it to the top of
the layer instead, now my squash and stretch is based on the top. So I will just put that back down at the base,
and we can move on. Let me set this back to 100. And the next thing I need to do is get the
Bend to work with that Scale Height. So all we have to do is animate a single property,
and all of our warping and squash and stretch is happening automatically. Now this next expression is a little bit more
complex, but pretty straightforward once you understand it. So I’m gonna add an expression to the Bend
property. Give myself a little bit of room. And we’re gonna start by defining a variable. Now a variable is just a way for you to write
your own shorthand within expressions. So I’m gonna start by typing var for variable,
space, and then we have to name the variable. So I’m gonna type S for scale, height, and
I’m gonna make that H capital. Now that capital H isn’t extremely important. That’s just kind of the common way of writing
code. Every new word is capitalized and it can just
make your code a little bit easier to read. And then I’ll put another space, equals, space. And then we need to tell this variable what
it contains. So I will grab the pick-whip and come down
to the Scale Height and let go, and finish this line of code with a semicolon so that
After Effects knows that’s the end of the variable. So now anytime that I type sHeight, After
Effects will interpret it as this line of code that references the Scale Height. Now I’m gonna drop down two lines and we’re
going to write a linear expression. Now a linear expression is just a way to interpret
one range of values into another range of values. So let’s just write the expression and then
I’ll explain how it works. So we’re gonna start by typing linear, open
parenthesis, and then sHeight. And again, that will reference this line of
code. Then I’ll put a comma, zero, comma 200, comma
50, comma negative 50, then a close parenthesis and a semicolon to finish off that line. So what is this saying? The linear expression is first looking for
a property. So we told After Effects to look at the Scale
Height property right here. Then it needs four values. A minimum and maximum input range, and a minimum
and maximum output range. So it’s gonna look at that scale height property
when it’s between a value of zero and 200. And I chose those two numbers because I’m
never going to set my Scale Height lower than zero, and I’m never gonna set it higher than
200. So that is the minimum and the maximum input
range. Then it needs to know, what do you want to
remap that range to be? So when the Scale Height is set to zero, I
want the Bend property to be set to 50. And when the Scale Height is set to 200, I
want the Bend to be set to negative 50. Now if I click off and adjust the Scale Height,
you can see what’s happening. The Bend property is automatically changing
based on the Scale Height. And because we linked the Vertical Distortion
to the Bend, that is also being adjusted. So with these two effects and a few simple
expressions, we’ve created a squash and stretch rig that warps and deforms in interesting
and unique ways, and automatically calculates our squash and stretch all based on a single
property. So if I just set a keyframe and press U to
bring up that keyframe, I could literally animate this entire squash and stretch rig
with a single property, something that would have taken me a lot more time if I was having
to keyframe each one of those properties individually. I’m gonna get rid of these keyframes. Set it back down to 100. And there’s actually another feature of the
Transform effect that’s gonna come in handy when you’re animating things that use squash
and stretch. And it’s the Skew part of this effect. If I adjust the Skew, you can see that it
warps our layer in another interesting way. And in this instance, I would want my Skew
Axis to be set to 90 degrees. And as I adjust the Skew now, you can see
that it’s based on where the anchor point is. So the Skew property allows me to lean my
layer in one direction or the other. This in combination with the squash and stretch,
can make things like bounces and jumping much easier to control. And another benefit of using the Transform
effect, is again that all of the squash and stretch, the skewing, everything is contained
within that effect. So I can resize this layer, reposition it,
rotate it, and none of that transform the actual layer will mess with the Transform
effect. So your squash and stretch, the skew, the
warp, is all independent of those transform controls. So that’s very handy when moving around and
animating your layers. Let me get this Scale back to 100 and the
Skew back to zero. So the way that we set this up is really for
the character to be based on the ground. So when I do this squash and stretch, you
see that it’s based on where we put our anchor point down on the imaginary floor. But what if I wanted this character to start
at the ground, jump up and hit the ceiling, and then squash and stretch off of that? Well, then we’d need to move the anchor point
to the top. We’d need to keyframe it from the base for
when it jumps off the ground. So we can have the squash and stretch there. But the way that we’ve set this up, really
doesn’t work for things like hitting into the ceiling. We would want the fat part to be at the top,
rather than at the bottom. So instead of keyframing and having to mess
with the effects that we’ve already set up, instead we could just duplicate these two
effects, adjust them for the top, and have two separate controls. So I’m going to rename this Warp Bottom, and
Transform Bottom. And then I’m going to duplicate both of these
effects. I’ll drag it to the bottom, and then I’ll
rename these, Warp Top and Transform Top. Alright, so I’ve got Warp Bottom, Transform
Bottom, Warp Top, Transform Top. First thing I need to do is make sure that
I have the Top Transform selected, put the anchor point up at the top, and something
already is messing up. What’s going on? Well, when I duplicated these effects, the
expressions stayed exactly the same. So these expressions that you see are red,
are still referencing the original effects. So I’m gonna select my layer and double tap
E to bring up all of the expressions. Give myself a little bit more room down here. And we need to go to the Transform Top, Position
expression, and change the referenced property. Right now it’s referencing the Transform Bottom,
which you can see right there. All I have to do is go into that expression
and change Bottom to Top because that’s what we renamed the effect. Now my layer went back to where it’s supposed
to be. And as you can see, I can move this anchor
point around and the position follows it. So that’s great. Now we just have to do the same thing for
all the other expressions. Wherever it says Bottom, just go in and type
in Top. Do that for the Warp effect as well. Once all that is done, now I have this secondary
control for squash and stretch that’s operating independently of the bottom Transform and
Warp. So now that we’ve got all of our expressions
referencing the right properties, we need to adjust some things so that it looks like
this is crashing into the ceiling. So let me just put it up at the top of the
composition, and I will squish it down. Now like I said before, I want the fat part
to be at the top, not at the bottom. Now let me close up the Transform Bottom and
the Warp Bottom just so we can focus on the top controls. And we need to go to the Vertical Distortion
and inverse that value. Now this is extremely simple. All we have to do is go into that effect and
add at the end of it, times negative one. Then click off and you see that now that Vertical
Distortion is inversed. The fat part is now at the top and I can adjust
this and it’s working exactly the way it needs to. Perfect, but what if it needs to go on to
the side of the comp and squash into the side instead? Well let’s go ahead and build out controls
for that as well. I’ll collapse these two effects and duplicate
them again. Bring them to the bottom and rename them Warp
Right and Transform Right. Then I’ll again double tap E to bring up the
expressions and collapse all of the ones that I don’t need to see. And I’ll start with the position again, changing
Transform Top to Transform Right. Then I’ll in to the other expressions and
do the same thing, replacing top with right. Okay, now everything is referencing correctly. I’ll set the squash and stretch for the top
back to 100, and come down to my Transform Right and adjust this Scale and you can see
that we need to make some adjustments. So, first of all, let me just put this back
to 100. We need to put the anchor point to the right
side of the layer. And I’ll align this to the right side of the
comp. So when I adjust the Scale Height, it’s based
on the right point on the layer, but the warping is completely off. The first thing we need to do is go to Warp
Right and change the Warp Axis from Vertical to Horizontal. So now that bulge is going to be going from
the top and bottom rather than the left and right. And then instead of Vertical Distortion, we
need to adjust Horizontal Distortion. So let me collapse the Warp and open it again
so we can see all of our properties. And I’m just going to cut the expression out
of Vertical Distortion, and then make an expression on Horizontal Distortion and paste it in there. And while I’m in here, I’m gonna get rid of
this inverse expression times negative one. Then I’ll click off. And I’ll make sure that I reset the Vertical
Distortion back down to zero, and now it’s almost working. If I adjust the Scale Height, you see that
now it’s going left to right instead of up and down, so that’s good. But when it’s squished into the wall like
this it should be getting wider on the right side not the left. So now I need to go into the Bend expression
and adjust my linear equation. So instead of having an output on the Bend
from 50 to negative 50, I need to reverse that, so negative 50 to 50. And by the way, while we’re adjusting this,
this range of 50 is just what I think looks nice, but you can feel free to adjust these
values to make something unique. Just make sure that these two values are proportional. So if you set this to negative 75, this one
should be 75. But anyway for this we’ll just put negative
50 to 50, click off, and now that is warping in the right direction. So I’ll adjust the Scale Height and we’ve
got our squash and stretch off the right side. I can set this back down to 100 and now all
that’s left is one for the left side. So let me duplicate these two effects one
more time. Bring them to the bottom. Change it to Warp Left and Transform Left. Double tap E. Collapse all the effects I don’t
want. And let’s do this process one more time. So I will first change right to left on all
of the expressions. Then I’ll move the anchor point for the Transform
Left to the left side of the layer. And then I’ll align this to the left side
of the composition just so it looks right. And I’ll adjust the Scale Height. So the wide part again is going on the wrong
side of the layer, so I need to add that inverse times negative one again to the Horizontal
Distortion, so times negative one. Now the wide part is on the left side of the
layer where we need it. And it’s all working exactly the way it needs
to now. So I could easily animate this bouncing off
the walls, the ceiling and the ground. Now all I have to do to get ready for animation
is a keyframe on the Scale Height property for each one of these Transform effects. And then I can press U on the keyboard to
bring up those keyframes. And that’s all I have to see to be able to
do squash and stretch on any one of the sides of the layer. So let me just put this back in the middle. I’ll reset this to 100. And now I’ve got the bottom squash and stretch,
the top squash and stretch, the right and the left. Now that we’ve done all of that work, we can
easily apply this rig to any layer by saving these effects as a preset. So if I click on my layer and press E to bring
up all of the Effects, I’ll just select them all, come over to my Effects & Presets, click
on this little drop-down menu and say Save Animation Preset. And I’ll give it a name, Squash&Stretch. Hit Save. After Effects will take a second to save that
preset. Refresh my list and now if I were to grab
say my little chiclet character. I’ll bring him out. I can type in squash. There’s my preset. I’ll double-click to apply it. Press U to bring up the keyframes. All of those default keyframes I set are already
there. Everything is already set up except for the
anchor points. Now if we really wanted to dive deep into
the expressions, I could have set this up to automatically place the anchor points to
the top, bottom, left, and right of the layer, but in this case I have some room around my
character, so I don’t actually want the anchor point to be all the way down here. I want it to be right here. So for this specific rig, I don’t think using
an expression to snap those anchor points would be the best option. Having the flexibility of adjusting where
your anchor point is, is a good thing when doing this type of animation. So I just need to set my anchor points for
each one of these effects. And just like that, my squash and stretch
rig is completely set up for all sides of the layer. And the Skew works exactly the same. Again, basing it off of wherever the anchor
point is for that instance of the effect. And this can work on any shape, it doesn’t
have to be a square. If I were to change this to be a circle instead
of a square, the squash and stretch still works. You can see that its warping the shape in
a more unique way than if we were just using the Scale. And to prove that, let me just turn off the
Warp. You can see that when this is squash and stretched
with just the scale, it looks fine but it’s kind of plain. So adding this extra warp that deforms the
shape in a more unique way can really be a nice touch, adding some uniqueness to your
deformations. And that’s it. Now you can reuse this preset on any future
projects, never again having to think about setting up squash and stretch, with some added
controls, which make creating this type of animation very streamlined. So there you have it, a super simple method
for streamlining squash and stretch, while adding another level of detail to make the
deformations more unique. Putting all this work in up front, allows
us to cut out a long and painful keyframing process for lots of future projects. Thanks for watching. I hope that this lesson is valuable to you
and that it’s able to streamline your workflow and improve the look of your animation. We’d love to hear from you if you use this
technique on a project. So tag us on Twitter @SchoolOfMotion and show
us your work. And if you learned something valuable from
this video, please share it around. It really helps us spread the word about School
of Motion, and we truly appreciate it. And don’t forget to sign up for a free student
account to access project files from the lesson you just watched, plus a whole bunch of other
great stuff. Thanks again and I’ll see ya next time.

17 thoughts on “Advanced Squash and Stretch in After Effects

  • June 30, 2017 at 3:34 am

    The maintain equals 200, I never knew about that :')
    And this is a very useful tutorial, save a lot time. Great video mate *sob

  • August 22, 2017 at 2:37 pm

    This is Da)

  • September 30, 2017 at 6:39 pm

    The expressions are so small for me to read. Is it maybe possible to get them in to the description?
    Thank you so much. 🙂

  • November 1, 2017 at 5:45 pm


  • November 21, 2017 at 9:22 pm

    Great tutorial

  • December 19, 2017 at 10:39 am

    I have a problem with expressions: var sHeight = effect("Transform")("Scale Height");

    linear(sHeight,0,200,50-50); – they doesn`t work. The program says, that project contains an expression error. What should I do?

  • January 11, 2018 at 6:03 pm

    Wow, you rock!!! Maybe it's not so complicated (for me it is) but you made it look simple. The preset thing is useful as hell! Thanks . PD your voice and pace is really outstanding. m/

  • February 20, 2018 at 10:25 pm

    Thank you! These School of Motion videos are such a mixed bag… Having endured Joey's reckless teaching of bad habits, wasteful techniques, and use of the word "okay" at the end of every sentence, this comes as a breath of fresh air.

  • July 10, 2018 at 7:35 pm

    You don't show your shortcuts so it's difficult of us to follow what your are doing ?

  • July 13, 2018 at 12:09 pm

    does this work in 3D space too?!

  • July 19, 2018 at 6:03 am

    Hey Jake, great tutorial. The formula for maintaining the shape's area/volume is really inaccurate though. For example, if you had a square 10 units by 10 units it has an original area of 100. The way you've set things up, if the width is reduced to 50% (5 units) the height would become 150% (15 units) making the total area 75 (5 x 15). This means you've lost a quarter of the shape's area. This problem compounds as the scale value moves further away from 100% in either direction. At 10% width (1 unit) the height would be 190% (19 units) for a total area of 20 units. At that point, a full 80% of the shape's area has disappeared. The accurate way to maintain the shape's area is to set the width to the original width (100%) times the original height (100%) divided by the new height… so: width=10,000/height.

  • July 31, 2018 at 7:08 pm

    To maintain the same volume in a 2D shape, the result of : {width * height} must be always the same. Not the {width + height}.

  • August 15, 2018 at 10:07 pm

    Extremely useful and well done!

  • September 5, 2018 at 12:25 pm

    I attended Jake's class on skillshare and it was life changing or career changing!

  • February 19, 2019 at 6:03 am

    Mind blown, thanks for the amazing tutorial!

  • November 1, 2019 at 3:16 am

    That was really helpful. Thank you so much!

  • November 21, 2019 at 5:32 pm

    en español seria:
    var sAltura = effect("Transformar")("Altura de la escala");



Leave a Reply

Your email address will not be published. Required fields are marked *