Jump to content
  • Advertisement


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


How to implement bullets in 3D world

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

I have a game (3rd person view) where I move my mouse cursor as a crosshair to target enemies, the problem is how to implement : 1. my bullets direction in 3D world given the position of the mouse on the screen. 2. the best way to do collison detection of my bullets. I need to implement some sort of level of accuracy of my shooting process. Can somebody give me a good idea or article where I can read ??

Share this post

Link to post
Share on other sites
I''m not a 3D programmer, but I think that if you assume that the mouse cursor is positioned at location (mouse_x,mouse_y, Z) where Z is a constant > 0,
and the position is reletive to the player,
you can calculate the vector of movement from the position of the player to the mouse location.


(: I am what I am, more or less

Share this post

Link to post
Share on other sites
1. Your coordinate system is composed of 3 vectors - right, up, and look. All you have to do is figure out how to calculate the look vector. The look vector points along where you are looking.

There are two ways to find the look vector. If you are keeping track of your rotation angles (pitch, yaw, roll), you can calculate it easily using some trignometry. The second way is to extract it right from the modelview matrix. In openGL, its something like this (I didn''t try this code to see if it works):

GLfloat MV[16];
CVector look(MV[2], MV[6], MV[10]); // i think this is right

2. The type of collision detecting you implement depends on what type of collision detection system you are using right now. The quickest way to implement collision detection is use OpenGL''s support for picking. Check NeHe''s tutorials for an expample of this.

For my landscape engine I use raycasting through my quadtree to determine collisions.

Does anyone have experience with raycasting through BSPs? I am curious how computationally expensive raycasting through a BSP is, compared to an octree/quadtree.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!