Collision detection not working properly

Started by
1 comment, last by NDraskovic 11 years, 8 months ago
I have a really weird problem with my collision detection algorithm. I have a few static elements and one movable, and for now I just want to make the movable element stop when it collides with the static ones. I tried to solve this in 2 ways - by using BoundingSpheres that are created automatically for each mesh of the static elements (in this case, algorithm never returned the "true" value in the Intersect method, although the models obviously collide), and I tried creating independent BoundingSpheres with the same center as the models that I'm drawing. In this case I get some results (the Intersects method returns true value sometimes), but the routine I have is triggered at the wrong time. For example, there are 3 static elements in coordinates (-5.0f,0f,0f), (0f,0f,0f) and (5.0f,0f,0f). When I run the program there are 3 collisions (as they should be) but they all take place between the first 2 elements (but not exactly in front of them). The weirdest part is that in the same program I have a picking algorithm that works with the same BoundingSpheres perfectly (when I click the position where the BoundingSphere should be, the proper function is triggered). What could be causing this?
Advertisement
Seems to me the problem resides in the moving element. How do you keep track of the moving element's position?
I think I solved the problem, I was moving the BoundingSphere twice faster than the model itself, so naturally it intersected with other Spheres twice sooner.

This topic is closed to new replies.

Advertisement