Ball gets faster every time it hits another object

Hey Guys,

well, title says it all I guess, the ball starts to get really mad very fast and is bouncing of waaay too fast.

Any idea?


Hi @Johnny_Beatmann,

Welcome to our community! :slight_smile:

Try to remove the Physics2D material from the ball and set the Collision Detection Mode of the ball’s Rigidbody2D component to “Continuous”.

Did this fix it?

See also:

Despite my first comment, it does not :frowning:

maybe to add, ball starts normal speed, hits something, gets faster, hits something again, is carzy fast, goes out of bound, basically

and thanks for the nice welcome fo course :slight_smile:

Did you try to remove the Physics2D material from all game objects in your scene? If not, do that, please, because it might be that the bounciness increases the speed of your ball. That’s a known issue.

Which version of Unity do you use?

When I did this course, the problem of the ball acceleration was the tweaking of the velocity in the bounces. If it is that, the solution is saving the initial speed and comparing it after each bounce, and adjusting if it is too fast or too slow:

Ball velocity problems solved!

thanks both - montse, I do not have that code anywhere I think, can you tell me where it’s supposed to be?

Define a float myVelocity.

At the Start():

myVelocity = Mathf.Sqrt(xVel * xVel + yVel * yVel);

where xVel and yVel are the components of the initial velocity (I don’t know what names have you used).

Where you do the tweaking of the velocity:

myRigidbody2D.velocity += velocityTweak;
myRigidbody2D.velocity = myRigidbody2D.velocity.normalized * myVelocity;

with the names you use for velocity and velocityTweak.

But that solution is only if your problem appears after the tweak of the velocity lecture!

I hope it helps.

Indeed, the tweak is also a source of problems. Johnny didn’t mention it, so I didn’t think about it.

thanks guys, I wasnt able to make it work but will just skip it for now and just continue. I know it for sure is not the best way to learn, but with a limited time budget, I will just move on as I probably just messed up a number somewhere and it’s not worth it to stop here for weeks for this kind of a “test game” :slight_smile:

This topic was automatically closed after 28 hours. New replies are no longer allowed.

Privacy & Terms