Search code examples
c#xnacollision-detection

Collision Detection for arbitrarily sized, positioned and rotated rectangles in XNA


I'm working with xna in C# and in my game I will have a variety of space ships flying all over the place. They will each have an arbitrary rotation, size and position in space and I need a method to determine when they collide. Ideally the method would take two Rectangles, two doubles and two Vector2s for size, rotation and position respectively and return a boolean that indicates whether they have intersected or not.


Solution

  • Have a look at these links:

    Collision Detection Overview
    Collision Detection Matrices
    Putting Collision Detection Into Practice

    They show you a way to do pixel-based collision detection, which is more accurate than rectangle-based for irregularly shaped objects.

    Update 2021-01-17 (Martin Senne)

    Links of XNA have moved to

    XNA
    XNA - Collision