2D collision Detection

Apr 22, 2011 at 9:36 AM

Hi,

Im using Goblin UI2DRenderer to draw two circles and I want to do a collision detection to see if these shapes are overlapped. I assume that I cannot use XNA sprite collision detection since I'm not drawing a Sprite. Any help regarding the issue is much appriciated.

 

Thanks,

Regards

Janidu

Apr 22, 2011 at 10:55 PM

There might be an XNA function for this, I'm not sure.  But if not, you can probably code circle collision in 2D yourself pretty easily.  Just take the distance between the 2 centers; if it's less then radius1 + radius2, they are colliding/overlapping.  If you are storing your centers as vector2's, you can just subtract them from each other and then retrieve the .Length() property of the resulting vector2.

Apr 24, 2011 at 11:42 PM

Thank you so much. I solved it using 2d collision detection as suggested by you. 

Thanks for your time :)