Updated August 28, 2023
Introduction to After Effects Bounce Expression
Bounce Expression in After Effects is a type of expression through which you can add a bounce effect on your object for making bouncing animation with it. For using bounce expression, you have to type an expression in computer coded language in the expression box of a particular property of any object. You can copy free expression code from any free internet website for the bounce effect of the different properties of the object. So let us understand different parameters of this expression to easily understand this topic and have command on code of bounce expression, which we will apply on different transform properties of any animated object of after-effects in this topic.
How to Use Bounce Expression in After Effects?
We can learn using this expression in After effects for adding bounce expression on our object by following some steps of the application process of this feature of after effect. But before we start learning about this topic of after effect, we must look at the working screen of this software to understand this topic in a better way.
In the user screen of this software at the top, we have a Menu bar with several menus. Below this, we have a Property bar of active tools or images. Below this bar, we have three sections in which at left side we have Project panel along with Effect Controls tab, at the center, we have Composition window in which we can see our current working, at the right side we have some tabs such as Preview, Align, Effects & Presets, and some other tabs are there. You can adjust all these sections anywhere on the user screen of this software as per your choice.
Now let us have a new composition for learning about this topic. For new composition, go to the Composition menu of the menu bar and click on it. Choose the ‘New composition’ option from the drop-down list, or you can press Ctrl + N button from the keyboard as a shortcut key for having new composition.
A new composition settings box will be open. Adjust the parameters of this box according to your desired composition property and click on the Ok button for applying for desired settings.
A new composition will create like this. Now go to the tool panel of this software and click on the icon of the Rectangle tool for having this tool active. I will apply bounce expression on different transform properties of the rectangle shape made by this tool.
Now draw a rectangle of any size like this.
Now go layer panel of this software and click on Shape layer 1, then press the S button of the keyboard for having the Scale property tab of this shape. Now set two keys from 0 to 100 percent that means set 0 value of scale at first key.
And 100 percent value of scale at second key.
Now click on the stopwatch icon of scale property with the mouse button by holding the keyboard’s Alt key. Once you click, an expression box will come in the keyframe section of this scale property.
Now type this expression in this box, or you can copy-paste it from here. In addition, you can get this type of expression from free internet websites.
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}
}
if (n == 0){
t = 0;
}else{
t = time – key(n).time;
}
if (n > 0 && t < 1){
v = velocityAtTime(key(n).time – thisComp.frameDuration/10);
amp = .05;
freq = 4.0;
decay = 8.0;
value + v*amp*Math.sin(freq*t*2*Math.Pl)/Math.exp(decay*t);
}else{
value;
}
Now you can see the bounce effect in scale property by playing it. Moreover, you can make changes in the bounce effect by changing any of these three values of this expression as per your choice.
Now let us type code for adding bounce expression on the position property of this shape. First, go to the layer panel and the select layer of shape again, then press the P button of the keyboard for having position property.
Now add two keys in position property and animate it from middle of composition window to bottom of it, which means at the first key place this rectangle at the center of composition window and second key place this at the bottom of the composition window.
Now make a click on the stopwatch icon of position property of this shape by holding the Alt button of the keyboard, and an expression box will add in the keyframe section of the timeline of this software.
Now type this expression in this box, or you can copy-paste it from here. In addition, you can get this type of expression from free internet websites.
e = .7;
g = 5000;
nMax = 9;
n = 0;
if (numKeys > 0){
n = nearestKey(time).index;
if (key(n).time > time) n--;
}
if (n > 0){
t = time - key(n).time;
v = -velocityAtTime(key(n).time - .001)*e;
vl = length(v);
if (value instanceof Array){
vu = (vl > 0) ? normalize (v) : [0,0,0];
}else{
vu = (v < 0) ? -1 : 1;
}
tCur = 0;
segDur = 2*vl/g;
tNext = segDur;
nb = 1; // number of bounces
while (tNext < t && nb <= nMax){
vl *= e;
segDur *= e;
tCur = tNext;
tNext += segDur;
nb++
}
if(nb <= nMax){
delta = t - tCur;
value + vu*delta*(vl - g*delta/2);
}else{
value
}
}else
value
Now you can see the effect of bounce expression on the position property of this shape by playing it.
You can make changes in these two values of this expression for making the change in the bounce of position property.
In this way, you can use bounce expression in the After effect.
Conclusion
Now, after this article, you can understand what Bounce expression is in After Effects and how you can type expression for getting it. You can also learn how you can change the values of these expressions for having variation in bounce effect on the different properties of any shape of after-effects.
Recommended Articles
This is a guide to After Effects Bounce Expression. Here we discuss How to use Bounce Expression in After Effects and how you can change the values of these expressions. You may also have a look at the following articles to learn more –