# Angular velocity doesn't affect a bouncing ball.

I’m having a head-scratching physics issue that I hope someone can help me solve.

I’m trying to replicate the effect that spin has on a bouncing ball. To test this out I have instantiated a rigidbody ball object, set it’s max angular velocity, set its angular velocity and let it fall to the floor. What happens is that the spin only affects the bounce of the ball on the second bounce, but not the first… seems weird to me!

If you watch the video below, you will see what I mean. Look at the rigid body angular velocity value in the inspector and you’ll see that it is completely unchanged by the first bounce!

w76jf8

Here’s the code:

``````    RigidBody ball = Instantiate(ballPrefab);
ball.transform.position = dropLocation.position;
ball.maxAngularVelocity = 1000f;
ball.angularVelocity = (spinDirection * spinAmount);
``````

Using add torque gives the same results

BUT, if I try making the ball kinematic, setting the angular velocity, then make it non-kinematic, it works as expected - giving me the spin effect on the first bounce!

Anyone have a clue what is happening here?

I can replicate your results by just dropping a sphere (I avoided Instantiating a prefab to keep things as simple as possible). There is a test scene attached for 2020.2.1f1.

I found that the problem was related to size (but not inertia tensor) and the fixed timestep. Reducing the timestep in Edit - Project Settings - Time - Fixed Timestep to 0.01s restored normal behaviour, you will need to tune this value to your setup.

Summary of tests (all with constant inertia tensor, no drag):
Scale: 1.0, Fixed Timestep = 0.02s, OK
Scale: 0.5, Fixed Timestep = 0.02s, Problem
Scale: 1.0, Fixed Timestep = 0.02s, Sphere collider radius halved, Problem
Scale: 0.5, Fixed Timestep = 0.01s, OK
Scale: 1.0, Fixed Timestep = 0.01s, Sphere collider radius halved, OK

I also tried reducing angular velocity to maintain tangential velocity at the contact point, but this made no difference.

Sorry, I don’t know enough about PhysX to say why this happens.

Obviously, there is a computational overhead to reducing the fixed timestep.

2 Likes

I experience the same issue. How did you change isKinematic? In the same frame?

Using this does not work on my side

``````body.isKinematic = true;
body.isKinematic = false;
body.velocity = velocity;
body.angularVelocity = angularVelocity;
``````

and this

``````body.isKinematic = true;
body.velocity = velocity;
body.angularVelocity = angularVelocity;
body.isKinematic = false;
``````