I'm trying to create this game (break the wall) and I have a question : When the ball hits the paddle it's angle should change accordingly, but how? Any one knows and can help me?

thank you!!

有帮助吗?

解决方案

As Soner wrote, it is impossible to tell without seeing some code. So this answer makes some assumptions that might or might not apply to your code. Anyway, the problem could be solved as follows:

Assume that we have the ball's direction and velocity as a vector. The paddle's normal will be a vector, too. Then you need to reflect the velocity at the normal with

velocity := velocity - 2 * normal * dot(normal, velocity)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top