PDA

View Full Version : Help with Bullets



Unreal Player
05-30-2005, 01:03 PM
Hi. I have worked on the bullets and enemies to my game due on wed. all day today and I just can't figure out how they can check to collide with eachother.

I have already figured out how to figure out if the player (FPS) collided with a building, but it's so much more difficult to check with the bullet and the alien.

I've tried many things, and I just can't seem to get it to work, can anyone explain to me what I would need to do to get this to work.
Thanks in advance.

dorbie
05-30-2005, 01:11 PM
Many games approximate a complex target with a simple bounding box or sphere.

Do a web search on ray casting it should help you.

Unreal Player
05-30-2005, 02:00 PM
yeah the alien is just a simple box with a texture on it, I just don't know how to detect to see if the bullet hit it.

jide
05-31-2005, 12:29 AM
with some maths and physics as usual !

Ehsan Kamrani
05-31-2005, 01:19 AM
I believe that you should use from the vectors. the viewer location and the enemy location in the world coordinate system can make a *reference vector*. Then you should compare your direction( you can use from some maths to make a vector based on your direction)with that reference vector.If they are equivalent, then a hit has been occured.
I suggest you to move to the www.gamedev.net. (http://www.gamedev.net.) They have some msg boards and can give a better idea to you.
-Ehsan-

glTracy
05-31-2005, 01:50 AM
If your bullet is as quick as light, the problem is simplified to be if the straight line in which direction your bullet goes is across the alien;
If your bullet has a finite speed, that is to say , the enemies have the chance to avoid being hitted, in my opinion, you may provide a variable
to record the position of each bullet, compared with the enemy's position every frame until they satisfy the certain case which means the bullet hits the enemy.
and that depends on the reference object you choose.
Sphere would be a good choice as you should just compare the radius and the distance between bullet and the enemy which has the possibility to be hitted.

ZbuffeR
05-31-2005, 02:09 AM
glTracy, the way you describe would allow bullets to go through aliens, because before hitting it will not collide, then next frame it has already passed the alien.
Best would be to check segment to box collisions, with start and end points being the previous frame and current frame bullet position.