ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Bouncing character

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Milena Malchiodi
Bouncing character
on Jun 6, 2014 at 2:30:59 pm

Hi everyone!

I'm trying to animate a character jumping between 3 "bases" and then, stay still in the last one.
I want this character to have some elasticity, like a rubber ball, or something like that.

I have tried with two different expressions in the position, inertial bounce and just bounce:


elev = degreesToRadians(75);
v = 1900;
e = .7;
f = .5;
g = 5000;
nMax = 9;
tLaunch = 1;

vy = v*Math.sin(elev);
vx = v*Math.cos(elev);
if (time >= tLaunch){
t = time - tLaunch;
tCur = 0;
segDur = 2*vy/g;
tNext = segDur;
d = 0; // x distance traveled
nb = 0; // number of bounces
while (tNext < t && nb <= nMax){
d += vx*segDur;
vy *= e;
vx *= f;
segDur *= e;
tCur = tNext;
tNext += segDur;
nb++
}
if(nb <= nMax){
delta = t - tCur;
x = d + delta*vx;
y = delta*(vy - g*delta/2);
}else{
x = d;
y = 0;
}
value + [x,-y]
}else
value


This one was pretty close, but the positions while the bounce is occurring, are just uncontrollable.

Any idea or help, will be great! Thanks so much, and sorry for the bad English.

-MiL-


Return to posts index


Filip Vandueren
Re: Bouncing character
on Jun 7, 2014 at 11:54:28 am

If I want precise bounce locations, i reverse my problems:
I actually keyframe the positions where I want to have an impact, and let an expression only figure out the arcs the character should follow in-between those impacts.
At it's most basic, this expression for position:


heightFactor=1;
p=position;
if (p.numKeys>1) {
nk=p.nearestKey(time);
prevKey= nk.time<time && nk.time<p.key(p.numKeys).time ? nk : p.key(Math.max(1,nk.index-1));
nextKey = p.key(Math.min(p.numKeys,prevKey.index+1));

l=length(prevKey.value, nextKey.value);
t=linear(time,prevKey.time,nextKey.time,0,Math.PI);

p.value-[0,Math.sin(t)*l*heightFactor];

} else {
p.value;
}


How high the letter jumps between positions is auto-calculated based on the distance between the two points.
Getting a convincing bounce takes some moving in time and space of the keyframes, but on the upside you get total control over where the letter lands.

I've got a more advanced version that has actual bounce and squash with expressions in scaling. it's a work in progress.



Return to posts index

Filip Vandueren
Re: Bouncing character
on Jun 7, 2014 at 6:47:24 pm

Here's an example of my auto-bounce expressions. Not bad for 6 position keyframes eh…

Automatic Bounce example


Note: this is a text-layer with a freeware dingabt font "creatures"

there are expression controllers for how high the character jumps,
how much squash and stretch it has in the air,
how much and how long there is squash at impact (at the keyframes)
and how much skewing (or rotation) along the path the character does. (that's pretty subtle in this example)


Here's another one with a Gill Sans 'O' and all the settings very pronounced a la Preston Blair:

Bouncing O



Still a work in process, a bit glitchy at the final keyframe, and the controls need to be more intuitive.
I'll keep you guys posted when it's ready to be shared.

Actually it's not super-complex: some sine-Math and loads of interpolations.
The main trick is in pausing the position-interpolation for a few frames around the keyframes so the scaling has time to to a bounce…



Return to posts index


Jason Jantzen
Re: Bouncing character
on Jun 7, 2014 at 7:32:19 pm

That's pretty slick, Filip. Keep us updated on that!

Jason Jantzen
vimeo.com/jasonj


Return to posts index

Milena Malchiodi
Re: Bouncing character
on Jun 7, 2014 at 10:51:42 pm

Filip, thanks so much for the detailed answer.

I've tried it, and it worked very well just for the bounce. I've finally keyframed the scale, to make the skewing of the object. So, believe me when I tell you I'm very interested (and PLEASE keep me updated) in the other expression you're working on.

Again, thanks a lot for the help!

-MiL-


Return to posts index

Filip Vandueren
Re: Bouncing character
on Jun 8, 2014 at 11:35:59 am

Instead of putting all the expressions here, I'll post an animation preset (after effects CC, but might work in older version).
Warning: code is a bit messy, still a work in progress, feel free to add/ameliorate…

7596_autobounceprestonv2.ffx.zip

Some explanation on my sliders:

- heightfactor: How high the ball jumps in respect to how far away the contact-poinst are (remember: you only keyframe where the ball lands.
- motionstretch: how long the ball is stretched out just before it hits the floor (stretch see pic below)
- impact timing: how long does the ball stay still in the impact position while contracting (squash) relative to the time between contacts
- impactsquash: how flat does the ball get at impact relative to how far it has jumped.
- skewfactor: how much does the ball lean along the motion path
- Skew checkbox: Apply the skew factor to text skew?
- Rotate checkbox: Apply the skew factor to layer rotation ?

the anchor point should be at the bottom of your layer. Which is the default for most text-characters. Where-ever I say Ball I mean character…
It works equally well on other types of layers but it's up to you to implement skew with a transform effect
Have fun!

The sliders all influence each other, which is why this is a work in progress…




Return to posts index


Filip Vandueren
Re: Bouncing character
on Jun 9, 2014 at 11:45:44 pm

found this thread from 5 years ago where I was working on a similar problem:
No squash and stretch though :-)

not the "usual" bouncing-ball question...
http://forums.creativecow.net/thread/227/13854



Return to posts index

Milena Malchiodi
Re: Bouncing character
on Jun 11, 2014 at 6:00:01 pm

Thank you so much for taking the time to help me!

I'm a newbie in the expressions thing, I have never worked with animation presets, but I'll give it a try.

Again, thank you :)

-MiL-


Return to posts index

John Gardner
Re: Bouncing character
on Apr 14, 2017 at 7:50:11 pm

Hi Filip,

I love this expression that you developed! Have you made any additional adjustments since version 2?

Talk with you soon,
John


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]