Archived

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

hits in a 1st person shooter

This topic is 5577 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

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 this post


Link to post
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 ]


::evolve::

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites