ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

not the "usual" bouncing-ball question...

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Michele Busiello
not the "usual" bouncing-ball question...
on Aug 13, 2009 at 2:17:44 pm

hi!

i've seen so many bouncing-ball-expression-threads in the internet but none of them helped me on my issue.i want to animate a puppet who is juggling with a (soccer)ball.
here is a live-action example: http://www.youtube.co/watch?v=Ipv8n9xWzQI&feature=related

the problem with most of the bouncing expressions is, that once you set up the script, the ball bounces for itself.
but i need a bouncing ball expression where i can define the ball-impact position by hand and let the ball bounce in relation to the points i defined. is there anyone who can help me ?

thanks!


Return to posts index

Ryan Hill
Re: not the "usual" bouncing-ball question...
on Aug 13, 2009 at 5:09:49 pm

Well, I'd be tempted to flat-out animate it.

I guess you could try one of those existing bouncing ball expressions, take every constant built into the expression and pick-whip it to a slider value. Then you have to change the sliders every moment the ball gets kicked.



Return to posts index

Filip Vandueren
Re: not the "usual" bouncing-ball question...
on Aug 13, 2009 at 6:15:05 pm

I have an expression that adds the arc movement inbetween keyframes.

I took your example move and stabilized it, then I made a circle shape and animated the position with hold-keyframes for every impact on the foor or body. Just 2D positions:



Then I added this expression to the position keyframes:


if (numKeys>1) {
kick=100; // strength of each kick

// get the previous & next keyframes
nk=nearestKey(time);
prev_k=(nk.time >time && nk.index>1) ? key(nk.index-1) : nk;
next_k=key(Math.min(prev_k.index +1,numKeys));

// force linear interpolation
x_pos=linear(time,prev_k.time,next_k.time,prev_k.value,next_k.value);

// calculate a Sine to simulate bounce
// (I find that sine^0.85 more accurately, though not perfectly, models gravity)
ang=linear(time,prev_k.time,next_k.time,0,Math.PI);
y_bounce=Math.pow(Math.sin(ang),0.85)*kick.valueAtTime(prev_k.time)*[0,1];

// base the height of the bounce on the amount of time between keyframes.
duration=next_k.time-prev_k.time;

x_pos-y_bounce*duration;

} else {
value
}

Result:


Already there is some convincing bouncing going on, but we need to vary the strength of the kick, as you can see near the end, sometimes it needs a real yank.

I put an expression control slider named "kick" on the ball layer
and pickwhipped to change the 2nd line to:

kick=effect("kick")("Slider"); // strength of each kick

Now I keyframed the Kick slider, unstabilized, and I wound up with this, which is a somewhat accurate simulation. Discrepancies lie in spin on the bal, Z-depth movement, and air-resistance (and of course the stabilize wasn't that great to begin with)

But that's all irrelevant, since you're starting from an animated character.



As I said, this just animates an arch between position keyframes. If you want the ball to bounce away after your character did his last kick, you'll have to animate some further contact points on the floor and decrease the kick slider untill zero.

This expression is set up for 2D, but it's quite easy to adjust to 3D positions should need be.






Return to posts index


Filip Vandueren
Re: not the "usual" bouncing-ball question...
on Aug 13, 2009 at 6:27:52 pm

Depending on how your character is rigged,

We could just set layermarkers on the foot-layers at the time of impact,
The ball could then derive the position where it needs to bounce, and the speed at which that foot is moving through space

-> zero extra keyframes, just animate your model...


But again, that might be taking it a bit too far ;-)



Return to posts index

Michele Busiello
Re: not the "usual" bouncing-ball question...
on Aug 14, 2009 at 1:07:00 pm

hi filip..

first off i want to thank you for the great effort you took in figuring out how to solve my problem!! your result looks great..though i posted that ball juggling clip just to show what i mean. im actually not working with the clip itself but i think your solution could be the answer anyway. unfortunately i got an error message when i tried to paste your code in the position property of the circle layer. the error message was this:

"after effects warning: function kick.valueAtTime is undefined. - Error occurred at line 15. Comp: "test" layer 3("shape layer1") property: "position".

Since im still a newbie in the world of expressions..im not skilled enough to figure out for myself why i got this error. maybe you could give me a hint what im doing wrong. that would be great!

thanks!



Return to posts index

Filip Vandueren
Re: not the "usual" bouncing-ball question...
on Aug 14, 2009 at 1:55:32 pm

Oops,
that was my fault.

the ValueAtTime only makes sense after you've assigned a slider to vary the Kick value.

So either, you do that as I described in the rest of the post, or if you want the kick to always be the same, leave it at kick=100;
and change the line:

y_bounce=Math.pow(Math.sin(ang),0.85)*kick.valueAtTime(prev_k.time)*[0,1];

to:

y_bounce=Math.pow(Math.sin(ang),0.85)*kick*[0,1];




Return to posts index


Filip Vandueren
Re: not the "usual" bouncing-ball question...
on Aug 14, 2009 at 1:56:58 pm

[Michele Busiello] "im actually not working with the clip itself but i think your solution could be the answer anyway."

I know, but this was easier than animating a character myself to illustrate how it works ;-)





Return to posts index

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