Bouncing collision response

BlitzMax Forums/BlitzMax Beginners Area/Bouncing collision response

Leo Santos(Posted 2009) [#1]
Hi everybody. I'm having trouble achieving proper collision response based on a collision normal. I'm a complete noob when it comes to math, so even though I've looked through all examples I could find (Snooker balls physics, the Billiards example by Joseph 'Phish' Humfrey, etc.) I end up in trouble trying to adapt their solutions to mine, simply because I'm doing it blindly - I don't really understand what's going on, so when something doesn't work, it's very hard to know what to do...

That said, I got much farther than I had before, this time using polygonal/circle collisions, mostly thanks to Dave 'Oddball' Williamson poly collisions code. The ONLY thing I'm still having trouble is achieving a bounce against the collision object.

Here's some example code I took from the main program and simplified so it only has circle to circle collisions. Please note that I'm not trying to move both objects in the collision, only the "MainBall" object.



It seems to work at first, but then you realize that the ball is bouncing exactly at the collision normal angle, instead of "mirroring" its original movement at the collision point. I know where the problem is (at the "Set new speed" section), I just don't know how to fix it...

Any help would be greatly appreciated.
Thanks!


Warpy(Posted 2009) [#2]
making things bounce


Leo Santos(Posted 2009) [#3]
Fantastic! That was quick! :-D
I'm adding a bookmark to your page, Christian, it is really helpful...

Here's the fixed code, it may help someone else out there: