Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 3d model which rotates around my screen, it's always on the Z axis = 0 where everything of my 2d images are. My 2d images fly out of the center and get bigger to give the view as getting closer. I'm trying to detect a collision so I can disable my 2d images to load new ones into the game.

My collision detection isn't working at all and I'm wondering if anyone can shed any light on this.

foreach (coins coin in coins)

            if ((coin.getCoinXPosition() + scale < getModelXPosition() - scale) &&
                (coin.getCoinXPosition() - scale > getModelXPosition() + scale) &&
                (coin.getCoinYPosition() + scale < getModelYPosition() - scale) &&
                (coin.getCoinYPosition() - scale > getModelYPosition() + scale)) 
                coin.coinVisible = false;

share|improve this question
"Isn't working at all"? What have you tried? – Anko Feb 5 '13 at 12:56

Use a BoundingBox structure that the XNA framework will provide you with - in this case you can find the documentation just right here. Simply create a box for all your stuff; with the Z-axis set to 0 accordingly and use the Intersects method to test. Hope this helps!

share|improve this answer

Another option is to project the 3D model into the target plane and then find the bounding edges (all outer edges) of the result. From this you can find a hull to build a set of convex polygonal shapes via ear clipping for a "real" physics engine like Box2D or Chipmunk or so on.

More complex by far but more accurate, if that matters to you at all.

If you just want the bounding box, you can find that by projecting the model's vertices or projecting its existing object-aligned bounding box, if you don't have an existing 3D AABB.

Converting a 3D AABB to 2D is pretty easy, and basically boils down to tossing out the off-plane coordinates and converting the correct on-plane coordinates to simple X,Y and width,height values (or min/max X,Y values if you use those for your AABBs).

share|improve this answer

Your Answer


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.