Bounce Effect Code or Expression in After Effects
Expressions are a great way to add some extra interest and realism to your animations. Using an expression to control the position of your layers can give you a lot of flexibility and Expressions are a great way to add some extra interest and realism to your animations.
Using an expression to control the position of your layers can give you a lot of flexibility and control over your animation. In this tutorial, we’ll take a look at how to add bounce ball effect with expression.
First, let’s take a look at what the After Effects Bounce Ball Effect is and how it works. The effect uses an expression to control the position of your layers. This expression is based on the physics of a bouncing ball.
When the ball hits the ground, it loses some energy and slows down. The amount of damping can be controlled by changing the parameters of the expression.
To do this, we’re not going to struggle with keyframes. We will use Expression. Thanks to expressions, we can easily apply such difficult animations to our project. We will make two different examples.
One of these effects is to give the appearance of a ball dropped from the top down. You can paste the following code into the Position expression field and edit it according to yourself.
e = .5;
g = 20000;
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
We use this After Effects preset code for an object that you give a scale effect. We use this code to give the object an elastic look.
amp = .1;
freq = 2.0;
decay = 2.0;
n = 0;
time_max = 4;
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 < time_max){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{value}
Expression logic is very important. As you can see, by adding a few lines of code, we can make these animations much more realistically than we would do manually by keyframing. If we try to do them without expression, we will both waste time and the result will not be so realistic. Through these expressions, we can make bouncing effects or stretching effects very easily.
Popular Tutorials
Audio Spectrum is when the rhythm of an audio file is animated…
I will explain how to create a text from random letters in…
I’m talking about keyboard shortcuts that you will want to press to…
I’ll show you have to make a simple sound wave with After…
When you import a vector file in After Effects and enlarge it…
Today we will explore how to use the Parallax effect in After…