caculating bullet vector?

Started by
9 comments, last by DevLiquidKnight 20 years, 3 months ago
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?
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.
Why would you need to use the camera''s position when computing the bullets direction?
-YoshiXGXCX ''99
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.
enum Bool { True, False, FileNotFound };
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]
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.
Milk is for babies
how u get point 1 and 2 ? 0.o
point 2 is your look vector, point 1 is your position vector.
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 :-)
enum Bool { True, False, FileNotFound };
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.

This topic is closed to new replies.

Advertisement