Jump to content
  • Advertisement

Archived

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

DevLiquidKnight

caculating bullet vector?

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

In directx i made a bullet class that handels all my bullets I fire im having problems with now using my cameras x,y,z and the left, right, up, back vectors to use them to determain the path of my bullet anyone have a good resource on this?

Share this post


Link to post
Share on other sites
Advertisement
Well, if the back vector faces backwards, then then negate it and you have a forward vector, which would be the direction the bullet travels - forward!

Or, the cross product between the up and right vectors will give you a forward vector.

Share this post


Link to post
Share on other sites
In a first person shooter, the bullet travels from the camera position down the center of the screen (where the crosshair is). In third person mode, it starts where the gun is, and travels in the pointing direction of the gun.

If you know which way the player will move when he/she presses "forward" then you can use the same information to figure out how the bullets will move.

Share this post


Link to post
Share on other sites
quote:
Well, if the back vector faces backwards, then then negate it and you have a forward vector, which would be the direction the bullet travels - forward!

Or, the cross product between the up and right vectors will give you a forward vector.


anyone got a better example 0.o u guys kinda confused me im new to direct3d and i did get the bullet to follow my camera nd all that its just not going right direction I dont know how to caclulate the vector between point a, and b to determain how much to incremnet in x,y,z coordinate each time it updates? lol if u know what i mean

I get what your saying I just dont know what it might look like, the camera im using for the overall camera movement is alot like the one on gametutorials.com 0.o if that helps

[edited by - DevLiquidKnight on January 17, 2004 5:05:35 PM]

Share this post


Link to post
Share on other sites
p1 - point 1
p2 - point 2

so....

vx = p2x - p1x
vy = p2y - p1y
vz = p2z - p1z
dist = sqr(vx*vx +vy*vy + vz*vz)

vx = vx/dist
vy = vy/dist
vz = vz/dist

There''s normalized vector for you.

Share this post


Link to post
Share on other sites
How do you figure out where the player moves to when he moves forward? The bullet should be the same, except faster, and with no turning or breaking :-)

Share this post


Link to post
Share on other sites
The bullet direction isn''t going to be the same as the player movement direction, unless your player can fly. Because it you''re looking upward and you press forward, you''re only going to stay on the ground and not move into the air.

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!