views:

29

answers:

1

As a hobby, I'm developing a 2D game. I've got some basic collision detection implemented using a separating axis method. When two objects collide, I project one of them out of collision along the axis that has the least amount of overlap.

The problem I'm encountering is that when an object is moving fairly quickly the axis that has the least amount of overlap isn't always the correct direction. The best example I have is when an object is moving down (along the + y axis) due to a simulated gravitational pull and collides with an environment object close to an 'edge' (as in the edge of a cliff). If the object was falling quickly enough, the axis with the least amount of overlap winds up being the x-axis, and the object is pushed sideways along the x-axis.

What is the best way to handle fast moving objects? I've considered moving the falling object in small increments, which seems like it adds a lot of extra overhead. I've also considered giving the environment objects a 'preference' of which axis to project the falling object, but that seems messy and error prone.

Is there a way to do it without adding a lot of extra overhead?

+1  A: 

I finally managed to find a good article describing sweep-tests in case someone else stumbles on this post with the same question. The article has more, but the link below describes collision between axis-aligned bounding boxes, which is what I'm using:

link text

Pimpl
Well, you can also check out continuous collision detection -- http://www.gamedev.net/reference/programming/features/ellipsoid-ccd/
vdeych
Also, I know you're doing this as a hobby, but if you want to look through good 2D CCD code, check out Box2D (which also has a C# port called Box2DX if you're into that sorta thing). Open-source and well-maintained.
vdeych
Thank you for the suggestions. The stuff on CCD looks very interesting.
Pimpl