Activity › Forums › Adobe After Effects Expressions › spring effect after keyframes
-
spring effect after keyframes
Posted by Karinov Mouja on February 25, 2011 at 5:53 pmhello,
I keyframed the scale of a layer, from 0 to 100; I want to add a bouncing effect (as Mr. Dan Ebberts explained on Motionscript) after the second keyframe. But the probleme is that the speed doesn’t continue smoothly after the 2nd keyframe; I have to adjust the amplitude and the frequency manually to acheive a smooth transition from the keyframed animation to the bouncing animation :Sis there a solution for this?
thanks in advance.
Eric Mc guire replied 14 years, 9 months ago 4 Members · 9 Replies -
9 Replies
-
Karinov Mouja
February 27, 2011 at 6:45 am -
Dan Ebberts
February 27, 2011 at 4:24 pmTry this:
freq = 2;
decay = 1;
mult = .05;if (numKeys > 1 && time > key(2).time){
t = time - key(2).time;
a = velocityAtTime(key(2).time-.01)[0];
d = a*mult*Math.sin(t*freq*Math.PI*2)/Math.exp(t*decay);
value + [d,d]
}else{
value
}
Dan
-
Karinov Mouja
February 27, 2011 at 6:26 pmthanks a lot Dan..
this is what I’m looking for 🙂I’d like to ask you about 2 things:
can you please explain this sentence:
(a = velocityAtTime(key(2).time-.01)[0];) (till now I can’t figure out how “velocity” works :Swhy do you put this variable: mult =.05?
(d = a*mult*Math.sin(t*freq*Math.PI*2)/Math.exp(t*decay);) -
Dan Ebberts
February 27, 2011 at 9:23 pmvelocityAtTime just picks up the rate at which the scale parameter is changing at the time of the second keyframe. That way, the bounce amplitude is higher for layers that were going faster before they hit the second keyframe.
The multiplier just attenuates the effect to get into a range that looks right. Adjust it to suit your taste. If you take it out (or set it to 1), with a fast scale-up like you have in your example, you’ll get a pretty extreme oscillation.
Dan
-
Blai Graell
March 21, 2011 at 10:22 amHi Dan.
Is it possible to do the same with keyframes in x,y,z rotation values of a 3d layer? I tried to apply this same expression to the y rotation value but it repports this message:
“Class ‘Number’ has no property ot method named ‘0’ Expression disabled”
One more thing. I’m trying to do the same with position keyframes, but the result is the layer bouncing in a weird 45 degrees diagonal angle.
Thanks in advance.
-
Dan Ebberts
March 21, 2011 at 4:27 pmThis version should work for rotation or position:
freq = 2;
decay = 1;
mult = .05;if (numKeys > 1 && time > key(2).time){
t = time – key(2).time;
a = velocityAtTime(key(2).time-.01);
d = a*mult*Math.sin(t*freq*Math.PI*2)/Math.exp(t*decay);
value + d;
}else{
value
}Dan
-
Blai Graell
March 22, 2011 at 3:39 pmThank you very much, Dan.
Yesterday I was really in a hurry so I had to manage the solution by myself. I found a lot of help in your site and succeeded to type two expressions that worked. I’m really new in expressions and I’m sure there’s a more simple way to achieve the same, but they worked anyway.
For position (3D):
freq = 5;
decay = 5;
mult = .002;if (numKeys > 1 && time > key(2).time){
t = time – key(2).time;
a = velocityAtTime(key(2).time-.01)[0];
b= velocityAtTime(key(2).time-.01)[1];
c= velocityAtTime(key(2).time-.01)[2];
x= a*mult*Math.cos(t*freq*Math.PI*2)/Math.exp(t*decay);
y = b*mult*Math.cos(t*freq*Math.PI*2)/Math.exp(t*decay);
z = c*mult*Math.cos(t*freq*Math.PI*2)/Math.exp(t*decay);
value + [x,y,z]
}else{
value + [0,1,2]
}for rotation:
freq = 4;
decay = 1.5;
mult = .08;if (numKeys > 1 && time > key(2).time){
t = time – key(2).time;
a = velocityAtTime(key(2).time-.01);
d = a*mult*Math.sin(t*freq*Math.PI*2)/Math.exp(t*decay);
value + [d]
}else{
value
}Thanks again.
-
Eric Mc guire
August 9, 2011 at 12:23 pmAwesome!! Thank you very much Dan!!! The last expression you’ve posted works perfectly with 3D layers. I am kind of a beginner in AE, but I don’t understand why they don’t implement this in the software. Wouldn’t it be terrific to control the decay, amp, etc with a slider instead of expressions values? Thanks again Dan!!!! : ))
Reply to this Discussion! Login or Sign Up
