Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

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'm new to XNA, and have just started looking into collision detection. I've managed to get a bounding sphere around my first person camera object and i want to check the collision between that and the walls of my cube. e.g. enter image description here

this is a cube i have built in Maya and it is 1 combined mesh. What i want to do i check my bounding sphere against the inside of the walls. and also allow the myself to enter in and out of the holes in the sides and th top. My first thought would be using each vertex to test against collision but i have no idea how to do this, since this is the first time attempting. Can anyone point me in the right direction?

share|improve this question
If you want to save yourself some work, you may want to use a physics engine with XNA - it will provide all the collission detection functionality you need. Have a look at this question:… – Marcin Seredynski Feb 14 '13 at 14:29

For this model, I think I might be tempted to create a compound bounding structure where there is one box that encompasses the whole model (level1 box), then 6 individual boxes for each major wall/side (level2 box), then lastly, a box for the passage way from outside to inside(level3 box) attached to its respective level2 box. Since your model is pretty simple & symmetrical, determining min, max for each box doesn't seem too hard.

The logic flow would be something like:

if(intersects level1 box)
  foreach (level2 box l2b)
     if(intersects l2b)
      if(!intersects l2b.level3Box)
         //collision occurred

Alternatively, have a look at the ship sample on the app hub site (requires premium membership), it creates an octtree for the model and uses it to narrow down which model triangles to test the camera against.

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.