Skip to content

Bouncing Ball

Bouncing Ball

The fundamentals of animation

In this tutorial, we will reproduce a classic animation tutorial, the Bouncing Ball. With it, we will explore various material properties of a ball whilst learning about the inner workings of Ragdoll.

Version 1.0 - Up to date

Written for Ragdoll 2021.08.06 and above, but should still apply for 2021.06 and newer.

Estimated Time

  • 🕐 10 minutes

You will learn

  • ✔️ How to convert a polySphere into a "rigid"
  • ✔️ How to tune physical properties such as bounciness and friction
  • ✔️ How to configure the solver for accurate high-frequency motion

Where to find help

If you find or run into any issues with this tutorials, here's what you can do.


Motivation

Why should an animator simulate a ball bouncing, rather than just keyframe it?

If you are new to animation or in a neighbouring field such as modeling or lighting, it might seem silly to consider such a trivial task for simulation. But as the more seasoned animator knows, getting the trajectory of any free-flying object right is incredibly hard. It can mean the difference between a believable character, and a character that looks like Earths gravity varies for the duration of a single jump, or one that appears to be on a different planet altogether.

With that in mind, although a single ball bouncing on a flat plane may seem trivial, it can be enough to challenge even the most senior of animators.


Setup

For this tutorial, all you need is an empty Maya scene. So go ahead and clear out all of those references and meshes with hours of history on it and let's get crackin'!


Poly Sphere

Let's make our ball out of a regular Maya polySphere.

  1. Run Sphere from the Polygon Primitives submenu of the Create main menu
  2. Translate the sphere to Translate Y = 5.0
What about NURBS?

Yes, if you prefer, you can also use a NURBS sphere.


Dynamics

With our sphere in place, let's give it some physical properties by turning it into a Active Rigid.

  1. Select pSphere1
  2. Run Active Rigid from the Ragdoll Menu

That's great! Except hm.. It's not really a bouncing ball just yet.


Bounciness

Default settings make the ball rather dull, so let's try introducing some bounciness via its material properties.

  1. Select pSphere1
  2. Increase Bounciness = 1.0
What does 1.0 mean?

It means 100%! Technically, it means any force produced by the ball hitting the ground is reversed in its entirety with no loss of energy what-so-ever.


More Bounciness

The reason the ball stops bouncing is that even though our ball is 100% bouncy, the ground is not. Like dropping a bowling ball on grass or a wooden floor. For perfect bounce, they both need to be 100% bouncy.

  1. Select rScene
  2. Set Ground Bounciness = 1.0
Where did the ground come from?

Ragdoll creates this ground automatically for you whenever the first rigid is made. It can be disabled by setting Use Ground = Off on the rScene node.


Even More Bounciness

Around the 11-second mark of the video above, you'll notice the ball suddenly comes to a halt. As if it suddenly remembered it isn't actually a bouncing ball anymore. Why is this? 😯

The default values are tuned for the simulation of ragdolls (surprise surprise!) so in order to accurately simulate just a ball we need to make some tweaks.

  1. Select rScene
  2. Go to the Advanced tab in the Attribute Editor
  3. Set Bounce Threshold = 0.1
What does Bounce Threshold mean?

It is how small of a bounce Ragdoll should consider to be a bounce, until it eventually stops it from bouncing.

A value of 0.0 theoretically means the objects would never stop bouncing. No matter their Bounciness. Each bounce would simply get smaller and smaller into infinity!

In the real world, objects would naturally come to a halt at some point due to friction in the air and along the surfaces of the two objects. With Ragdoll, we only have approximations of such things so as to make a simulation run in real-time, and as a result we need to manually tune this parameter until we find a value that suits our taste.


Infinite Bounciness

Let's keep pursuing that sweet sweet perfect bounce.

  1. Select rScene
  2. Reduce Air Density = 0.0
What is Air Density?

This attribute can be used to emulate the effect air has on your simulation. It can be used to achieve effects other than air too.

Air Density Effect
0.0 Vacuum
5.0 Water
10.0 Mud
100.0+ Sand

Technically, the attribute is a multiplier of Translate Damping and Rotate Damping of each rdRigid node, which can be used to affect individual rigids.


Finalise

Now that we have complete control over our ball, let's put it to good use.

You have learnt

  • ✔️ How to convert a polySphere into a "rigid"
  • ✔️ How to tune physical properties such as bounciness and friction
  • ✔️ How to configure the solver for accurate high-frequency motion


Initial Velocity

Give the ball a little push.

  1. Select pSphere1
  2. Run Hard Pin from the Controls submenu of the Ragdoll menu

A new node was created called a "Hard Pin", which tells Ragdoll exactly where this ball should be at any given moment. We can now animate this pin which in turn animates the ball, until we "unpin" it.

  1. Select rHardPin
  2. Set the following keyframes.
Frames 1 2 3
Translate Z 0.0 0.5
Passive On Off


Trajectory

With our bouncing ball underway, let's gain a deeper understanding of what it looks like over time.

  1. Select rScene
  2. Go to the Visualisation tab
  3. Toggle Trajectories

Now, as every animator knows, this is not the trajectory of a bouncing ball. It looks as if the ball isn't actually touching the floor half the time, what's up with that? 🤔

Expected Result
✔️
Expected result
Actual Result
Actual result

This is a problem of resolution. Cameras have this problem too.

See how despite this most definitely not being a simulation (or is it?) we are still getting bounces that don't actually touch the ground! The reason is simply that a camera can only capture moments of reality. It can only sample it.

In this case, the ball did touch the floor, but the camera caught at a slightly different time. Shortly before and after contact. This is how you can think of Ragdoll too; a camera for physics.

Can you overeducate me?

With pleasure. 😁 Let's look at audio.

image

Notice how sound itself, represented by the curved line, is continuous - of infinite resolution - and that what we capture in our computers are samples of it, at some fixed resolution - typically at 44,000 fps or as it is more commonly known 44khz.

Ragdoll works like this too. Physics is continous, but Ragdoll can only provide you with snapshots of physics at a fixed resolution; the resolution of your framerate.

Is every bouncing ball tutorial on YouTube wrong?

A typical bouncing ball tutorial has the ball come into contact on whole frames. But because the time between each bounce is decreasing, it is impossible for every bounce to land on a whole frame.

So in a way, yes, they are wrong! Science says so!

Should I change the way I animate?

Well, it depends. Take motion blur for example.

Because you see, the final position from a video recorded tennis ball is only half the story. Motion blur isn't the result of only these samples, but of the actual continous motion. As light hits the lens inbetween the shutter opening and closing, the ball is still moving.

To accurately reproduce this effect in your animation or with Ragdoll, you still need those inbetween positions of the ball. Just so that your renderer can throw those away once it's done computing motion blur.

Even without motion blur, your eyes and brain still interprets the ball not hitting the ground as though it floats or hits an invisible obstacle. So for the greatest sense of realism when everything has been said and done and the images actually reach your eyes (brain), you may still want to defy physics and realism.

Because at the end of the day, the animation curves isn't what you are making. They are mere tools for you to achieve realism in the final output picture.


Tennis Ball

Now that we've got some reference for a tennis ball, let's tune our settings to match.

  1. Select pSphere1
  2. Set Bounciness = 0.4

Let's also take it out of orbit and into Earths atmosphere by restoring the Air Density

  1. Select rScene
  2. Set Air Density = 1.0


Practical Examples

Now that we've got a ball, what could we possible do with it?


Squash

Now we can use what we've learnt and combine it with some traditional rigging to deform our ball!

We'll achieve this by reducing the size of our simulated ball, whilst keeping our Maya geometry the same. That will result in the Maya geometry actually intersecting the ground. We will then "fix" the intersection whilst preserving the overall volume of the mesh.

Let's go.

# Description Screenshot
1 Create a new Icosahedron with 4 subdivisions of triangles.

We will use this as the deformed version of our rigid.
image
2 Create a floor out of a box, we need something with volume. image
3 Parent Constrain pPlatonic1 to pSphere1.

Do not maintain the offset such that the new sphere follows the original sphere.
parentconstraint
4 Reduce the Radius of pSphere1 = 0.5 radius

With a radius less than our geometry, the geometry will naturally intersect with our ground. Let's compensate for this using a membrane deformer.

  1. Select pPlatonic1
  2. Run the following MEL comment
createMembrane

Not much will happen yet, apart from a small offset along Y. We'll get to that. But first.

  1. Select pPlatonic1
  2. Shift select pCube1
  3. Run the following MEL command
collideMembrane

Great, so the ground pushes against the ball, solving the intersection we created earlier by reducing the Radius.

Let's tune the membrane

  1. Select pPlatonic1
  2. Set these attributes
Attribute Value Description
Gravity 0.0 Remove that offset along Y
Thickness 0.01 Get the ball and ground closer
Steps 5 Fix the intersection with the ground
Compression Resistance 5 Maintain the volume of the ball
Bend Resistance 2 Spread the deformation
Stretch Resistance 1 Smoother overall surface

From here, you can tune Bend Resistance for more or less stiffness in the overall surface, and Steps for more or less of an effect.


Pong

Let's recreate a classic game of pong, with two animatable paddles.

# Description Video
1 Create a new rigid.

We won't need any geometry, the default shape will be a Sphere
2 Let's look from a side view.
3 Create the floors.

Same thing, except this time as a Passive Rigid and we'll adjust the shape to a Box.
4 Create the paddles.
5 Create a Soft Pin, and animate its Guide Strength across the first two frames.

We'll use this to give the ball its initial velocity. You can tweak the position and strength to give it more or less speed in your chosen direction.

Now let's tune some settings.

  1. Select every rigid
  2. Set Friction = 0.0
  3. Set Bounciness = 0.0
  4. Select rScene
  5. Set Air Density = 0.0
  6. Set Use Ground = Off
  7. Set Bounce Threshold = 0.1

Finally, we can animate the paddles. Winning is a little easier than normal Pong, since we can not only freeze time, but rewind it too. 😅


Incredible Machine

In the 1990s, there was a game developed called The Incredible Machine. In it, you were tasked with creating an obstacle course for a set of mechanical contraptions and physical objects in order to get some object from one place to another.

Coming soon


Cached Playback

Tweak an entire trajectory on-the-fly with Maya Cached Playback. Play with gravity and witness how it affects the slopes.

Coming soon


For Science

The shortest path isn't necessarily the fastest.

Coming soon


Pool

A classic game of pool with balls constrained onto a 2D plane.

Coming soon


Troubleshooting

Let's have a look at some common issues.


Vibrating at Rest

There is no right value for Bounce Threshold, it's an art. And it depends on the size of your scene and rigids, their shape, how fast they move and the look you are after.

When the threshold is too low, Ragdoll can get into an infinite bounce like this.

To address this, increase the threshold until it stops.


Last update: 2021-08-27