Rigidbody2D bouncing ball

Godot Version

4.2

Question

I’m a beginner having trouble with a breakout clone. I’m attempting to make the ball bounce, but it stops when colliding with the boundaries. I’ve increased the bounce on the rigidbody but that didn’t fix anything.

apply_force() might work a bit better, may be

1 Like

Your programming it like it’s frozen or a character body; move_and_collide doesn’t need to be called and I believe prevents the bounce you want. You can try removing move_and_collide for a single apply_impulse to start the ball moving. Or change it to a CharacterBody2D and use move_and_collide’s result to determine the bounce vector.

1 Like

If you are using a CharacterBody2D you need to check if there was a collision and then calculate the bounce when that happens.
You will have to change how you move your ball there.
Or use a RigidBody as suggested.

I made a video about 2D trajectories that turned into a breakout clone at the end. You can use it as reference.

The specific bounce code using a CharacterBody2D is here in this timestamp

You can remove the change in velocity(line3-4 and line7-8) due to drag and gravity if your game doesn’t use that.

1 Like

Thank you I will watch that video

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