#### Archived

This topic is now archived and is closed to further replies.

# hits in a 1st person shooter

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

## Recommended Posts

Hi, I''m in the process of developing my first OpenGL game, its a basic first person shooter. I''m trying to work out how to register a hit when i shoot at something - mostly the bad guys in the game. I was wondering if i could do it using picking (a la the picking tutorial on nehe''s site)? The game is based "outdoors" and is 3d. I''m really stumped. I''m going to try using the google search engine to find stuff. I''d be grateful for any info, thanks PS I just joined gamedev and the place rocks!

##### Share on other sites
pseudocode:
struct bullet{    float x,y,z;    CVector direction};... somewhere in your updating routines...for(int i = 0; i < active_bullets; i++){   if(PointInCube(bullet.x, bullet.y, bullet.z, badguy.boundingbox))   {       badguy.playsnd(BADGUY_SNG_OUCH);       badguy.animate(BADGUY_ANIM_FLINCH);       if(badguy.health <= 0)       {           badguy.animate(BADBUY_ANIM_DIE);           badguy.destroy();       }   }}

this is a pretty general approach..
simplified explaination- check if a bullets coordinates
are within a bounding rectangle of an entity.

-eldee
;another space monkey;
[ Forced Evolution Studios ]

##### Share on other sites
I think he wants to know how to check with hitscan weapons, where there isn''t an actual traveling bullet, damage is just done to whatever he is clicking on. With traveling bullets like rockets etc its just simple collision detection, however, I am not sure about hitscan weapons.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 98
• 11
• ### Forum Statistics

• Total Topics
632974
• Total Posts
3009654
• ### Who's Online (See full list)

There are no registered users currently online

×