No ball bounce after GetMouseButtonDown

Hey, I’m levente and first of all sorry of my bad english usage I’m still learning this language. I’m at section 5 lecture 75.

So there is my problem:
After I finished the script as mentioned in the video I tryed it… And it’s working fine until the ball reaches the paddle first (after OnClick launch) and when reach the paddle the ball just stop bouncing.

Things I’ve tried:
I set the ball bouncines 1.
I’ve rewritten the full code of the Ball.
I’ve tried to rewrite the paddle code.

The Code:
Ball code


1 Like

Hi @Levente_Toth, welcome to the community - and your English is just fine :slight_smile:

Looking at your ball.cs code, you appear to be missing the OnCollisionEnter2D() method.

Hope this helps.

Still didin’t get it into work :frowning:

So just to check, at the moment you have this;

  • you run the game
  • the ball is on the paddle
  • you press the mouse button
  • the ball launches
  • it moves up and then comes back down the screen because of the gravity
  • when you place the paddle underneath, the ball just stops and doesn’t bounce

Is that correct?

Yes, after i launch the ball comes back because of the gravity and after I place the paddle underneath the ball just stops and doesn’t bounce anymore just rolls.

Do you have a Rigidbody2D on the Paddle?

Yes, i have Rigidbody2D attached to paddle.

Thanks for the screenshot. Try changing the collision detection to continuous.

Can you also take one with the ball selected so it displays its properties in the Inspector also please.

I’ve tried to change the collosion detection to continous but it doesn’t work.
here is a screen from a ball:

The CircleCollider2D is missing the Ball material.

1 Like

Okay i found out what is wrong with this I doesn’t set the Circle Colldier2D material to ball. :blush:
Thanks for advices :blush:

1 Like

lol - looks like we both spotted that at the same time… hehe…

Glad you have it sorted - happy bouncing :slight_smile:

Yea, I’ve just seen what’s wrong while I was waiting for your answer thanks for the help once again :slight_smile:.

Have a great Day!

1 Like

You’re very welcome and you too :slight_smile:

Privacy & Terms