user38789: I have applied 'bounce effect' following the rules. The first keyframe of scale was 0 and the second one was 100. but the scale gets bigger after second keyframe, increase its size.
Why is this happening? please help.

Bounce expression-

amp =2;
freq = 2;
decay = 4;

n= 0;
if (numkeys > O){
n = nearestKey(time).index;
if (key(n).time > time){
n--;
}}
if (n == O{t = 0;
}else{
t= time - key(n).time;
}

if (n > 0 && t < 1){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
Value;
}



user4426: I think the reason your shape is growing too large is because you have set the amplitude to above 1, ie greater than 100% of the original size.
I think this is based on Harry Frank's inertial bounce code.
If you use his code, and his suggested values:
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}

Applied to a scale control with two keyframes of 0% and 100%, you get this effect, which I think is what you're looking for:


38789: <p>I have applied 'bounce effect' following the rules. The first keyframe of scale was 0 and the second one was 100. but the scale gets bigger after second keyframe, increase its size.</p>
<p>Why is this happening? please help.</p>
<p><a href="https://i.stack.imgur.com/WCyPT.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WCyPT.gif" alt="enter image description here" /></a></p>
<pre><code>Bounce expression-

amp =2;
freq = 2;
decay = 4;

n= 0;
if (numkeys &gt; O){
n = nearestKey(time).index;
if (key(n).time &gt; time){
n--;
}}
if (n == O{t = 0;
}else{
t= time - key(n).time;
}

if (n &gt; 0 &amp;&amp; t &lt; 1){
v = velocityAtTime(key(n).time - thisComp.frameDuration/10);
value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);
}else{
Value;
}
</code></pre>
<p><a href="https://i.stack.imgur.com/eLYpY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eLYpY.jpg" alt="enter image description here" /></a></p>
 4426: <p>I think the reason your shape is growing too large is because you have set the <a href="https://en.wikipedia.org/wiki/Amplitude" rel="nofollow noreferrer">amplitude</a> to above 1, ie greater than 100% of the original size.</p>
<p>I think this is based on <a href="https://www.graymachine.com/top-5-effects-expressions" rel="nofollow noreferrer">Harry Frank's inertial bounce code</a>.</p>
<p>If you use his code, and his suggested values:</p>
<pre><code>amp = .1;
freq = 2.0;
decay = 2.0;
n = 0;
time_max = 4;
if (numKeys &gt; 0){
n = nearestKey(time).index;
if (key(n).time &gt; time){
n--;
}}
if (n == 0){ t = 0;
}else{
t = time - key(n).time;
}
if (n &gt; 0 &amp;&amp; t &lt; 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}
</code></pre>
<p>Applied to a scale control with two keyframes of 0% and 100%, you get this effect, which I think is what you're looking for:</p>
<p><a href="https://i.stack.imgur.com/wWmiL.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wWmiL.gif" alt="enter image description here" /></a></p>
