Sign in to follow this  

Collision Detection Woes

This topic is 3863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone. I am making an asteroids clone called Space Rocks. It is 3D/2D. The ship, bullets, and rocks only move on 2 axes, but the rocks rotate about three axes, making it have a more 3D feel. However, having the rocks rotate is giving me some collision detection issues. The bullets only hit the rock depending on the way it is rotated. I am only doing brute force collision detection, so I'm very sure that is not very effective. Can someone give me some help on some collision detection calculations that I can do when my objects are rotated? Thanks in advance for any help. P.S. I don't think it will help because this is only a logic/math problem, but I am using C++/OpenGL.

Share this post


Link to post
Share on other sites
if(RotateStatus() == StatusThatDoesntHit()) DontHit();
if(RotateStatus() == StatusThatDoesHit()) Hit();

Simple. Run that check after you check if it's collided in X/Y coordinates. Reading it now, it sounds kinda smart***, but it wasn't meant that way, so don't get mad for the accidental tone.

Share this post


Link to post
Share on other sites
You can either use a ray-triangle intersection, or else check to see if the point that represents the bullet position is behind each triangle in the asteroid (which would indicate that the bullet has penetrated, but probably "good enough" to detect the moment of collision). In either case, you need to take the bullet point and make it relative to the center of the asteroid, then rotate the point by the inverse of the asteroid's rotation. This will put the bullet point in model coordinates, so you can check the point against the asteroid geometry without having to rotate all of the triangles yourself, etc.

Share this post


Link to post
Share on other sites
Possumdude, the one you have stated is the one currently in use. It's not good enough to account for the rotations of the objects.

Edit: Well somewhat, it's the math that goes behind the 'RotateStatus' that isnt good enough.

Share this post


Link to post
Share on other sites
Well, great minds think alike... lesser minds must do the same ;)

I'd just do it in plain 2d, with the asteroids animated to look 3d. Then your RotateStatus would just depend on the animation frame, or you could slip in some math that gave it a Z coordinate (which would have nothing to do with the actual drawing) that would determine if the asteroid was above or below the plane of the bullet.

Share this post


Link to post
Share on other sites
Oh, well if you're going for full 3d then...
1) wouldn't it be easier to start with everything 3d?
and...
2) I will be of absolutely no help to you, because I couldn't tell 3D programming from a hole in the ground.

Share this post


Link to post
Share on other sites
Oh, well if you're going for full 3d then...
1) wouldn't it be easier to start with everything 3d?
and...
2) I will be of absolutely no help to you, because I couldn't tell 3D programming from a hole in the ground.

Share this post


Link to post
Share on other sites

This topic is 3863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this