Hello guys I'm new to godot and I'm trying to make a breakout game but I'm having troubles bouncing the ball in the correct way.

I'm using var collision = move_and_collide(velocity * delta) and velocity = velocity.bounce(normal) to make the ball bounce, btw the ball is a kinematic body.

It's works well most of the time, but sometimes I get some odd normals. Here is some normals that I printed:

(1, 0) (0, -1) (0, 1) (1, 0) (1, 0) (1, 0) (0.262366, -0.964968) (0, 1) (0.865071, -0.50165) (1, 0) (0, -1) (0.492536, -0.870292) (1, 0) (0, 1)

I just want the ball to bounce with a 45 degree to prevent the ball going horizontally for example.

I don't know if I can publish the code here so I posted on pastebin to not polute the post. Link to code The code is a bit messy since testing with godot but feel free to give sugestions to improve myself :)

Here's a friendly tip when debugging your scripts; it is very useful. If you click beside the numbers in the script editor, you can setup things called "breakpoints". When the game runs into a line with a breakpoint, it will pause the program and allow you to take a look at the variables from that point of the code. :)

You can use breakpoints in this case to figure out what "kind" of collisions are giving you those abnormal normals. ;)

Also, note that while the game is running in the editors scene tab there appears a text string saying remote, if you press it you can inspect the properties of the nodes in the running game instance instead of the scene in the editor itself.

Thanks Megalomaniak, already knew that one :) I'm still strungling with the "normals" problem any clue to help me?

Are your collision meshes that the ball collides with rectangular with sharp 90 degree corners? The normal values that 'look odd' seem like the (literal) corner cases to me. It might help to create collision polygons with beveled corners to bounce off of instead.

Makes sense, dumb me. I think I will try to change the normal so in such cases creates a normal of one of the sides.

3 years later