문제

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