Skip to main content
alastair-o
Participating Frequently
December 22, 2019
질문

How to animate tennis balls dropping out of a tennis can.

  • December 22, 2019
  • 1 답변
  • 264 조회

Hi, appreciate this isn't about error codes as such, however I'm having some trouble using AE to animate  tennis balls exiting a tennis can.

 

The can is opaque so the tennis balls will only be seen when they reach the lid and drop to the ground. 

 

To set the scene a little more, the can will drift across the screen as this is happening so the tennis balls (four in all) form a line on the ground. 

 

I believe masks are the best way to achieve this but I'm not sure what to mask or how to apply one here. I've already designed the can and balls. 

 

I've used masks successfully for text in the past but this set-up is a bit more intricate. 

 

Would be grateful for any guidance!

 

Thanks in advance.

 

이 주제는 답변이 닫혔습니다.

1 답변

Community Expert
December 22, 2019

Revealing the tennis balls is all layering. Depending on your design you may need more than one copy of the can. Parenting can help and an expression that simulates gravity and a bounce can help, but you should not have any need for masks unless the layer that contains the can does not have a transparent background. 

 

By far the easiest solution is to spend some mone on Newton, and amazing 2D simulation package from aeScripts.com

 

If you don't have the budget you can modify and expression shared by Dan Ebberts on motionscript.com and set up your comp like this:

The top layer is a null parented to the can and the opening layer that is below the balls. I just created the can with a rectangle and an ellipse, then used another lighter ellipse below the rectangle to give the balls a hole to come out of. 

 

Here's my modification of Dan Ebbert's expression:

 

 

elev = degreesToRadians(86);
v = 2500;
e = .6;
f = .5;
g = 5000;
nMax = 9;
tLaunch = thisLayer.inPoint - .5;
 
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

 

 

Right up at the top are the variables that I changed. here is my reasoning:

elev = degreesToRadians(86); // Reset to a very steep angle to match the speed of the moving can

v = 2500; // This is the velocity I needed to get enough elevation in the bounce

e = .6; // I needed a little less bounce

f = .5; // The friction is OK

g = 5000; // The gravity is OK

nMax = 9; The number of bounces is OK

tLaunch = thisLayer.inPoint - .5; // I adjusted the start time to be a half second before layer start so the ball is on it's way down

 

All that is necessary is to adjust the Y position to match the position of the null at the start of the layer and stagger the copies of the ball layer. 

 

You could also go to Dan's website and add in an expression to get the balls to roll and come to a stop.

 

That's the easiest and most realistic solution I can think of without spending any money. If you have a lot of work to do that requires simulations Newton is a very good solution to your problem.