Archived

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

yanuart

How to implement bullets movement in 3D world

Recommended Posts

I have a game 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 2. the best way to do collison detection of my bullets. Can somebody give me a good idea or article where I can read ??

Share this post


Link to post
Share on other sites
make a bullet struct/class/whatever, which has 2 3D vectors (one for position, one for velocity). to move it, add the velocity vector to the position one every frame. for collision detection, check if the line between the bullet''s position and it''s next position intersects anything else.

Share this post


Link to post
Share on other sites
Hi yanuar

For Bullet direction :
i would use 2 point to define the bullet front direction :
1st. the viewpoint position
2nd. unproject the mouse position at a certain z value (weapon range ?)

Then using the two points, you can define a direction vector for the bullet.
As for collision detection, i think krez''s suggestion is fine.

Share this post


Link to post
Share on other sites