ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Intertial Bounce Effect... but backwards?

FAQ   •   VIEW ALL Intertial Bounce Effect... but backwards? on Jan 14, 2015 at 8:05:02 pmLast Edited By Brent Taylor on Jan 14, 2015 at 9:26:06 pm

I've been using the inertial bounce expression from this website:

http://www.graymachine.com/blog/my-top-expressions

(Code Below)

I'm trying to do the same effect, but in reverse. In other words, rather than moving and then swinging to a stop, I want it to be at rest, swing bigger and bigger, and then go.

To see what I'm trying to do, use the code below on the rotation of an object. Put two points... one at 0 degrees and one at 90. Then just play the animation you get in reverse.

Any idea how to do that? I feel like there should be a simple tweak I can make to the code to do it, but nothing I've tried so far works.

Another step from that which would be really cool would be to be able to do both in the same animation.

Thanks for any help.

```amp = .1; freq = 2.0; decay = 2.0; 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 &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 }``` Re: Intertial Bounce Effect... but backwards?on Jan 21, 2015 at 6:13:44 am

Try this.

```freq = 2; decay = 5; delay = 0.15; dur = 0.12; myDelay = delay; t = time - (inPoint + myDelay); startVal = 539 ; endVal = 540; amp = (endVal - startVal)/dur; w = freq*Math.PI*2; ans=endVal + amp*(Math.sin(t*w)*Math.exp(decay*t)/w); [transform.position, ans] ```

--
Fahd Chishty
Motion Design Artist
MotionCue Re: Intertial Bounce Effect... but backwards?on Jan 21, 2015 at 5:46:57 pm

Thanks Fahd!

That's a good start but not quite what I'm looking for.

The way the position's movement starts small and then increases is great! Now we just need to apply it to the right thing...

Right now it doesn't respond to keyframing. Ideally it would do this between two keyframes like the inertial bounce script.

Also, this specifically outputs Position and doesn't work on other elements. What I want to do is affect the layer the expression is on (again like inertial bounce). I think that means affecting velocity.

I will mess around with your version and see what I can come up with. Open to suggestions as well. Thanks again. Re: Intertial Bounce Effect... but backwards?on Jan 23, 2015 at 8:35:52 am

To make respond to keyframes, you need to put values of startVal and endVal by keys.

startVal = key(1);
endVal = key(2);

Secondly, to solve the position only problem, I replace the transform.position by value
Or if you want to animate the 2nd value make it [ans, value]

```freq = 2; decay = 5; delay = 0.15; dur = 0.12; myDelay = delay; t = time - (inPoint + myDelay); startVal = key(1) ; endVal = key(2); amp = (endVal - startVal)/dur; w = freq*Math.PI*2; ans=endVal + amp*(Math.sin(t*w)*Math.exp(decay*t)/w); [value, ans]```

--
Fahd Chishty
Motion Design Artist
MotionCue