Search code examples
2dcollision-detection

2D collision for games without AABB


What exactly is the best way to detect 2d game collision? I use aabb's (axis-aligned-bounding-boxes) but if you have a big circle or something, you will be hitting it when your like 200 pixels away. Would the best way be to just see if the pixels in the 2 images are touching? please let me know a good method.

EDIT: Ok so now I realize how simple circle collision is. but say I have an oval or something that isn't really a shape. Or even a square that is rotated 45 degrees.


Solution

  • If you have circles you can use Circle-To-Circle collision. Just take the distance of the midpoints and compare it with the length of the radii. Beside that it really depends on what you need. There's a plethora of collision detection algorithms (mostly to speed things up, e.g. by using coherence between frames) but that's out of the range for a short general note and you'd need to specify your problem a bit more.