2
\$\begingroup\$

I am playing with Unity physics engine. I have a pool table and a cue ball. Both have Physic Materials. If I start the game, with the ball floating about 1m above the table, it falls and bounces (bounce depends and happens only if Physic Material, bounciness property is set to something above 0.5 ish.). But I have to have it between 0.8-0.9 bounciness for it to look anything like realistic. And even so after a bounce or two it stops and it doesnt look at all real.

The mass of the ball is set to 0.17.

I've tried playing about with the two Friction properties, but these seem to have no effect on this test. (currently I have these all set to 0.1)

Like I say, it will bounce two or even three times but then seems to come to an abrupt stop.

Also if you set the bounciness of both materials to about 0.9+ the bounces sometimes get larger after a smaller bounce before it.

Does anyone have experience playing with similar physics in Unity? And if so, what else should i change to tweak the behaviour.

The table itself doesn't have a rigidbody, only the balls do.

As an added complication to the question, wouldnt the ball roll slightly in some direction after it had bounced, rather than just bouncing directly up and down?

thanks

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

The realism of a physics simulation is the result of a lot of factors. A first easy step for games that need reliable physics would be to set the Collision Detection of a Rigidbody to Continuous Dynamic. It's kind of complex to explain, but essentially means that collisions will be using more correct data, at the cost of lower performance. Continuous Dynamic means that it does this with both static and moving objects, while Continuous means that it only does this with static objects.

You could also increase the number of physics updates per second to increase realism, but it's generally not worth it and the default 50/s is a good number.

The next step would be making your physics materials as close as possible to the real materials you're approximating.

First I'll explain the main concepts in use.

Bounciness is the elasticity of an object. When an object collides with another their bounciness values are averaged and used to calculate how much movement energy is canceled out by the other object (i.e: how much energy is lost in the collision). In essence, if two balls are moving toward each other, a fully in-elastic collision (bounciness = 0) will have the two balls together after the collision (moving or not depending on whether they had the same movement energy toward each other), while a fully elastic collision (bounciness = 1) will have the two objects basically swapping movement energy with each other (which if they have the same weight simply would mean that they swap speeds).

Friction is more complex, but is in essence a counter-force acting on an object in the opposite direction of another force while two objects are in contact. Static friction is how hard it is to get a still object moving. Dynamic friction is how quickly moving objects slow down. The value range is mainly 0 to 1 and is averaged across the two objects in contact, like with bounciness. If unsure, you can generally set both static and dynamic friction to the same value.

Since your test involves a ball falling straight towards a flat surface, friction will have no effect on the test, but is still very important for other interactions and should not be ignored.

Now, for selecting appropriate values:

Pool balls have a very high elasticity, so you should set your bounciness at close to 1. They also have very low Friction, so both static and dynamic should be set at close to 0.

I'm less certain about pool tables however. They probably have pretty low friction and bounciness, both around the range of 0.1-0.3 if I were to guess.


wouldnt the ball roll slightly in some direction after it had bounced, rather than just bouncing directly up and down?

In reality minor variances in the surface the ball collides with along with small side-movements from the drop of the ball will get the ball rolling slightly after landing. But for the simulation we have no such variances; the ball is moving directly toward a perfectly uniform flat surface, resulting in no side-movement.

\$\endgroup\$
3
  • \$\begingroup\$ hi and thanks for the helpful answer. I forgot to mention , I already changed it to Continuous Dynamic (tbh it didnt really change anything on my simple drop from 1m height test). I'm going to investigate the changing of the time step that you mentioned soon tho as I have not tried that. Also I completely agree with how you describe choosing the right figures for the physic materials. Also perhaps I can simulate the variance somehow to make it bounce not exactly straight (but also of course maintaining somewhat realistic behaviour on the table) \$\endgroup\$ Dec 15, 2018 at 1:06
  • \$\begingroup\$ This answer appears incorrect or incomplete. Tested in Unity 2018.4, Identical spheres with initial velocity set so they collide, each using the same physics material of bounciness 1 and 0 for all friction fields, will collide perfectly inelastically: i.imgur.com/V3E8sZo.gifv Detection mode has no impact. \$\endgroup\$
    – Johannes
    Sep 1, 2019 at 7:03
  • \$\begingroup\$ @Johannes sorry for the late response, but that's because of a setting called Bounce Threshold. Your test uses velocities that are too low to allow the spheres to bounce. It can be found in Edit->Project Settings->Physics. Manual page: docs.unity3d.com/Manual/class-PhysicsManager.html \$\endgroup\$ Jan 13, 2020 at 1:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .