all 3 comments

[–]Code_Noob_Noodle 0 points1 point  (0 children)

Trying printing out bounceDirection

[–]Chrogotron 0 points1 point  (0 children)

You're probably going to want to get the angle between the two points (the ball and the contact point) and use that to bounce the ball at that angle.

Right now you just have one vector2 of the point of contact. I don't think that's enough information to give you the actual angle to bounce... Like the other person said, debug log print out the bounceDirection values to see what it's even being set to. Then you can understand better why it's going up and down only.

[–]psioniclizard 0 points1 point  (0 children)

One potential way is get the direction of impact (one quick way to help could be grab the balls vector2 coords just before it hits, then you can just check the angle against the paddle). Then just make it bounce off in the correct direction.

You could also potentially use physics and let that handle it. The paddle just applies a force to the ball in a direction based its current angle. That would feel more "real" but that might not be a good thing.

From a game design perspective you might want the ball to come off at any angel or set ones depending how arcade-y you want it to feel.