Too random ball

Hello!

I have a small problem with my Block Breaker game.

My ball acts in an unpredictable way. Whenever it hits a couple of blocks at once, it slows down or speeds up. I set my game speed to a relatively slow pace (0.45), friction is 0 and bounciness is one. I’ve changed the Random Factor quite a lot, but it doesn’t seem to solve anything regarding the speed of the ball.

what should I do?

Hi,

Try to set the Collision Detection Mode of your ball’s Rigidbody2D component to “Continuous”.

Did you already implement Rick’s tweak which is supposed to prevent endless loops? If so, decrease the tweak values.

Hey Nina!

Sorry for the delay with my answer.

I did as you instructed, and it’s a bit better now, but now the problem is that if the ball is getting stuck vertically, the tweak constantly changes the angle of the ball upwards, so when it happens it gets stuck on the upper side of the screen and doesn’t come back down. It doesn’t gain enough angle to come back down. I tried to increase and decrease the tweak factor, but nothing works.

What should I do?

Does the ball get stuck in the corner, e.g. does it get caught in an endless loop moving vertically near the left or right edge of the game screen?

It doesn’t get stuck in the corner, but it doesn’t get caught in an endless loop exactly. Whenever it’s moving horizontally it tweaks itself a bit upwards, so when it goes into this loop on the top of the screen, where there are no blocks to change its course, the ball goes up, and then collide with the upper collider, goes a bit down, and tweaks itself back again. This is the loop I can’t solve.

Maybe you could test this solution:

Or this:

See my code, you have to normalize the ball speed after each collision.

Thanks! I’ll try them both and decide which one I like better.

I have another question. I tried to move the score at the bottom of the screen in the “game over”. I dragged the “game session” into the middle of the canvas, but when I play and loses, the scores stays at the bottom left corner of the screen.

What should I do?

Looks great, I’ll try it out.
Thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms