Skip to main content
Participating Frequently
March 2, 2026
Answered

Using a Bounce Expression?

  • March 2, 2026
  • 4 replies
  • 155 views

I animated a .png of an item falling, and rotating as it falls until it hits the floor. After the animation ended, I moved the CTI a few frames ahead and rotated it a bit to add a new keyframe, and moved the CTI again and rotated it again to make it seem more like a bounce when it hit the ground. I want to make the bounce seem a bit more natural. I spent some time online and I read about Expressions, and I copied some Bounce Expression that I found, and I want to paste it so I press alt and clicked on the Stopwatch for  Rotation to paste the Expression since this is the last thing that I added to the animation. The Expression editor opens with

transform.rotation

When I paste the following Bounce Expression after this it just gives me an error.

 

“This project contans an expression error: error 1 of 1. What am I doing wrong? Thanks in advance!

 

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

 

Correct answer Dan Ebberts

@MediaBound 

  1. No, the expression error message was because somehow, minus signs (-) in the expression had been replaced with em dashes (–) (I think) and some other weird character substitutions happened.
  2. Sure, you could just add a few additional position keyframes to provide the bounce motion.

4 replies

thepixelsmith
Community Expert
Community Expert
May 4, 2026

Hey you asked for an easier way, here are Ae add-ons that can automatically add bounce and other easing to keyframed properties.

Both the ones here are pay what you want so if you don’t want to pay for it just say zero.

Lord of the Eases (I made this one): https://thepixelsmith.gumroad.com/l/lordoftheeases

Ease & Wizz: https://aescripts.com/ease-and-wizz/

Jerron Smith | www.thepixelsmith.com
rose123412
Participant
May 4, 2026

Looks like the issue is with how the expression is pasted—transform.rotation shouldn’t stay there when you add a bounce expression. You usually need to replace it completely and make sure the expression matches rotation values (not position). Also double-check for syntax errors like missing semicolons or wrong variables. I ran into similar small errors while testing different setups, even when browsing stuff like https://downloaddeltaexecutor.org/delta-executor-pc/—tiny mistakes can break everything

Jimmylink
Participant
April 20, 2026

Hey,

The error you're seeing happens because the expression you copied is built for Position (3D Array), but you're trying to apply it to Rotation (1D Number). After Effects is getting confused trying to find X, Y, and Z axes on a property that just spins.

Replace everything in the Rotation expression editor with this version. It's cleaner and specifically designed for a 1D bounce wobble:

javascript

// 1D Bounce Expression for Rotationamp = 0.4;   // How far it wobbles back (Try 0.2 to 0.8)freq = 3.0;  // Speed of the wobbledecay = 6.0; // How fast it stopsn = 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 - thisComp.frameDuration/10);  value + v * amp * Math.sin(freq * t * 2 * Math.PI) / Math.exp(decay * t);}else{  value;}

Why this solves your specific error:

  • Old Code Problem: if (value instanceof Array) checks for [x,y,z]. Rotation doesn't have that, so it throws Error 1 of 1.

  • New Code: It simply takes the velocity of the rotation (how fast it was spinning when it hit the floor) and adds a decaying sine wave to it.

Pro Tip for Natural Bounce:
Make sure the keyframe right before the bounce has some motion. If the object stops completely for 1 frame and then rotates, the velocity will be zero, and the expression will do nothing. Keep the motion continuous into the floor hit.

🎨 A Note on Precision Tools for Creatives
*It's funny how much we obsess over a single keyframe curve or a 1-pixel alignment in our compositions, but we totally ignore the hardware we use to scrub that timeline. I used to use a gaming controller mapped to my timeline for scrubbing and 3D camera moves in After Effects, but stick drift kept throwing my playhead off by a few frames. If you ever use a gamepad for jog/shuttle control in your edit suite, you know how annoying that is.*

I keep the Delta Executor Official site bookmarked—not just for the Roblox stuff (which is their main thing), but because they have a surprisingly precise diagnostic tool built in. It helps me zero out my controller deadzones so my timeline scrubbing is buttery smooth. Even if you just do graphic design, it's worth a look for the clean UI alone.

Dan Ebberts
Community Expert
Community Expert
March 2, 2026

It looks like some of the syntax got mangled somewhere along the line. This should get rid of the error(s), but I’m not sure if it does what you expect:

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

 

Participating Frequently
March 2, 2026

Thank you. Is there a better/easier way to create the effect of a more natural bounce after an object lands on the ground based on what I described in my initial post?

Dan Ebberts
Community Expert
Community Expert
March 2, 2026

Your initial description confused me because you talked about adding the bounce expression to the rotation property, where I would normally expect to see it applied to position, so I’m having trouble picturing what your desired result would look like.