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 am new to XNA and I am having problems with collision detection when I rotate my sword. I am using a rectangle bounding box approach and I don't know how I can rotate my rectangle together with the sword sprite.

http://picpaste.com/pics/f10268c108e885498a4ae603ab030a60.1328941784.png

Any suggestions on how can i solve my problem is really appreciated. Thanks!

share|improve this question
    
add comment

2 Answers 2

up vote 2 down vote accepted

I believe this article will be of some help to you. It has sample code that will show you how to rotate the points on a rectangle but also show you how to use the separating axis theorem to detect collisions on a rotated shape (in this case your collision box). On a side note, the web site is also a great resource for learning XNA.

http://www.xnadevelopment.com/tutorials/rotatedrectanglecollisions/rotatedrectanglecollisions.shtml

One other solution might be to use a few points (instead of rectangles) that change when the animation changes. Then use those points to detect collisions. I've heard of storing these points alongside animation frame data in an .xml file. Might make for a simpler approach than using the separating axis theorem. Hope this helps. Good luck.

share|improve this answer
add comment

use a bounding circle instead with the 0-90 degree angle being the distance you can slash vertically for example.

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.