FORUMS: list search recent posts

Re: making text bounce

COW Forums : Adobe After Effects

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index   •   Read entire thread


cowcowcowcowcow
yikesmikes
Re: making text bounce
on Sep 23, 2007 at 8:05:03 pm

I found the no-creeping version for when you have an initial x velocity (thanks to the cow for tuning up the Search engine). If you change the last line of Dan's to this:

[position[0] + Vx0*(-Math.pow(2,-time) +1), floor - y]

Then you put the second line to have an initial x velocity, like this:

Vx0 = 300; // initial x velocity (pixels/second)

And you text is positioned at the top left of the screen, or just off-screen left, then you will get text that flies in from the left and bounces, skidding to a stop. Change the first line to give it y velocity makes it jump up and left before bouncing.

Anyway the whole expression might look like this:

For Position:

Vy0 = 800; //initial y velocity (pixels/second)
Vx0 = 450; // initial x velocity (pixels/second)
g = 2500; // gravity (pixels/second/second)
floor = 400;
e = .85; //elasticity

b = floor - position[1];
h = b + Vy0*Vy0/(2*g);
T = Vy0/g + Math.sqrt(2*h/g);

if (time < T){
y = Vy0*time - g*time*time/2 + b;
}else{
Vy = -(Vy0 - g*T);
while (true){
Vy *= e;
t = T;
T += 2*Vy/g;
if (time < T){
t = time - t;
y = Vy*t - g*t*t/2;
break;
}else if (T - t < thisComp.frameDuration){
y = 0;
break;
}
}
}
[position[0] + Vx0*(-Math.pow(2,-time) +1), floor - y]

For Scale:

Vy0 = 800; //initial y velocity (pixels/second)
Vx0 = 450; // initial x velocity (pixels/second)
g = 2500; // gravity (pixels/second/second)
floor = 400;
e = .85; //elasticity

d = .02; //squash factor
spd= 10; //speed of squash oscillation
decay= 10.0; //how fast squash slows down

b = floor - position.valueAtTime(0)[1];
h = b + Vy0*Vy0/(2*g);
T = Vy0/g + Math.sqrt(2*h/g);

if (time < T){
x = scale[0];
y = scale[1];
}else{
Vy = -(Vy0 - g*T);
while (true){
max_dev = e*Vy*d;
Vy *= e;
t = T;
T += 2*Vy/g;
if (time < T){
t = time - t;
x=scale[0]+max_dev*Math.cos(spd*(t))/Math.exp(decay*t);
y=scale[0]*scale[1]/x;
break;
}else if (T - t < thisComp.frameDuration){
x = scale[0];
y = scale[1];
break;
}
}
}
[x,y]

With these two expressions. if you started the text's initial position as just off-screen left, halfway up, then it will bounce on and stop in about the middle of the screen, with the floor at 400.


Posts IndexRead Thread 


Current Message Thread:





© 2019 CreativeCOW.net All Rights Reserved
[TOP]