Sign in to follow this  
Psychopathetica

Sweep AABB Collision/Response

Recommended Posts

Hi, I'm working on a pong style game thats gonna be a blend of Pong and Air Hockey in 2D with some realistic physics. However I ran into a speed bump...collision. Sure everythings all find and dandy using Bounding Box, or even Separation Axis Theorum, but when the puck goes too fast, it'll go through the paddle and not register a collision. I was fully aware at the time that using Sweep collision would be the solution, but I cannot find a decent piece of source code on Google worth using in my game. Now I recently saw this article found here:

 

http://www.gamedev.net/page/resources/_/technical/game-programming/swept-aabb-collision-detection-and-response-r3084

 

Looked very promising, however when I spliced his code into mine, it was awful. The puck slowed down as it got closer to the paddle, and got slower and slower, until it stopped at the paddle. Even when I shut off the physics, and just had the puck move at a constant rate of whatever value I gave vx multiplied by the collision time, it did the same thing. Also theres a limitation in his code, and he did admit there were limitations. It only works if one object is moving and the other is static. However in my game, I have 2 objects moving. The puck as well as what could be the paddle. Maybe if theres an SAT version of sweep collision and response out there. If anyone has any bright ideas on how I can successfully pull this off or knows of any other articles / links, I would appreciate it. Thanks in advance.

Share this post


Link to post
Share on other sites
c-up    324

It's a pretty low brow solution but if you only have 3 moving bodies (a puck and 2 paddles) then you could just run the physics with very small time steps.

Share this post


Link to post
Share on other sites
stu_pidd_cow    3136

Since you say the the puck is going through the paddle, you should probably make the puck the moving object, and make the paddle the static object (even though it is technically moving). This should have much better results.

 

The results you are getting now makes it sound like you haven't implemented it properly (maybe the broadphase or response is causing problems). Any chance you could supply  some code to show what you're doing?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this