Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Inertia expression keeps turning itself off

• Inertia expression keeps turning itself off

7 Members · 16 Posts
• Mike Tosetto

December 1, 2011 at 12:23 pm

Hi there

I’m working on a big project at the moment and I’m using this inertia (bounce) expression on lots of elements. It’s an expression I found online at the Motion Graphics Exchange website.

When the expression works, it works a treat but it constantly turns off and throws the following error:

After Effects warning: invalid numeric result (divide by zero?)
Expression disabled.

If anyone can help out here, I’d really, really, really appreciate it as it’s becoming quite painful and the deadline looms.

Mike

`// Inertial Bounce (moves settle into place after bouncing around a little) 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){ v = velocityAtTime(key(n).time - thisComp.frameDuration/10); amp = .03; freq = 1; decay = 15; value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t); }else{ value; }`

miketosetto dot com | bestiacollective dot com

• Dan Ebberts

December 1, 2011 at 3:44 pm

My guess is that the value of t must be getting large enough to cause the Math.exp() function to overflow. How far into the comp do you get the error (and what is the line number in the error message)?

Dan

• Mike Tosetto

December 1, 2011 at 9:06 pm

The AEP is getting quite big now and it’s about 2 mins long and growing. I’m using this expression on about 100 layers or so and often the layers are in pre comps of about 50 layers so it’s a reasonable project in size.

When AE throws the error, it tells me the layer name and says it occurs at line 20 so I think you’re spot on with thinking it’s to do with this part: Math.exp(decay*t);

Can it be fixed or written a different way? Do you have any suggestions?

Thanks for your help Dan, I really appreciate it mate.

Cheers

Mike

miketosetto dot com | bestiacollective dot com

• Dan Ebberts

December 1, 2011 at 9:20 pm

Try changing the first line of the last section from this:

if (n > 0){

to this:

if (n > 0 && t < 1){

Dan

• Mike Tosetto

December 2, 2011 at 8:53 am

Dan, YOU ARE AMAZING!!!

Solved the problem and I was able to work all day and hit my deadline. Like I said, I owe you a beer…

Hats off mate, can’t believe you solved it

Thanks again

Mike

miketosetto dot com | bestiacollective dot com

• Dan Simmonds

February 6, 2012 at 3:58 pm

I think this has solved my problem too

Cheers! 🙂

• jean mathis

June 2, 2012 at 12:07 pm

Well, this poisoned an ongoing project I have for two months, I have been looking for the solution everywhere and here it is. But who else than Dan could have solved this? I worship at your feet Daniel.
Cheers
Jean

• manojit ghose

February 8, 2013 at 11:56 am

thanks!

MG

• Danor Gerald

April 18, 2013 at 1:58 am

This is a lifesaver for an AE newbie. Thanks

• Ale Elizondo

February 4, 2015 at 3:05 pm

Dan I have the same problem but with a little difference , could you help me with this?:

I try use your solution :

if (n > 0){

to this:

if (n > 0 && t < 1){

but this no works in this case:/

`amp = .2; freq = 3; decay = 2; kf = 2; // only on 2nd keyframe   n = 0; if (numKeys > 0){   n = nearestKey(time).index;   if (key(n).time > time) n--; }   if (n == kf){  t = time - key(n).time;   v = velocityAtTime(key(n).time - thisComp.frameDuration/10);   temp = value + v*amp*Math.sin(freq*t*2*Math.PI)/Math.exp(decay*t);   x = temp[0];   y = value[0]*value[1]/x;   [x,y] }else   value`

Viewing 1 - 10 of 16 posts