Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've implemented some collision detection using separating axis theorem. Works fine for axis-aligned rectangles and two out of four possible right triangle orientations. For some reason when the hypotenuse is oriented down left or up right, the minimum translation vector being calculated is that of the normal of the base or height of the triangle rather than the hypotenuse that is being collided with.

http://i.stack.imgur.com/W5WHH.png

I've got a jsfiddle demo of my implementation. The center box and right side triangles all show a correct MVT when the collision box collides with them. The ones on the left side do not. Move your mouse over the canvas to move the collision box.

http://jsfiddle.net/XLtdB/

share|improve this question
1  
This is a problem somewhere in your code. You need to debug your code. Try writing out the algorithm on paper with pictures and see if your code follows the algorithm correctly. Overall I think this question is too localized since it's just your code that's the problem. –  Byte56 Jan 1 '13 at 16:32
    
You are making an undue assumption about which direction to move in checkNormal. –  eBusiness Jan 1 '13 at 23:17
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.