Archived

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

DevLiquidKnight

caculating bullet vector?

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
Zipster    2365
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
hplus0603    11356
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
Bouncer    145
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
Zipster    2365
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