Public Group

# Collision Detection Woes

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

## 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 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 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 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 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 on other sites
The reason it's semi-3d right now is when I get it working like it is, I hope to change to Complete 3d.

##### Share on other sites
Oh, well if you're going for full 3d then...
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 on other sites
Oh, well if you're going for full 3d then...
and...
2) I will be of absolutely no help to you, because I couldn't tell 3D programming from a hole in the ground.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633734
• Total Posts
3013587
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!