Game Development Reference

In-Depth Information

a
x
= 0

v
x
= v
m

x = v
x
t = v
m
t

Now looking at the
y
component, you know that the initial speed in the y-direction, as

the bullet leaves the rifle, is 0, but the y-acceleration is
-g
(due to gravity). Thus:

a
y
= -g = dv
y
/dt

v
y
= a
y
t = -g t

y = (1/2) a
y
t
2
= -(1/2) g t
2

The displacement, velocity, and acceleration vectors can now be written as:

s
= (v
m
t)
i
- (1/2 g t
2
)
j

v
= (v
m
)
i
- (g t)
j

a
= - (g)
j

These equations give the instantaneous displacement, velocity, and acceleration for any

given instant between the time the bullet leaves the rifle and the time it hits the target.

The magnitudes of these vectors give the total displacement, velocity, and acceleration

at a given time. For example:

s
= (
v
m
t
)
2
+
(
1
/
2
gt
2
)
2

v
= (
v
m
)
2
+(
gt
)
2

a
=
g
2
=
g

To calculate the bullet's vertical drop at the instant the bullet hits the target, you must

first calculate the time required to reach the target; then, you can use that time to cal‐

culate the
y
component of displacement, which is the vertical drop. Here are the formulas

to use:

t
hit
= x
hit
/v
m
= n/v
m

d = y
hit
= -(1/2) g (t
hit
)
2

where
n
is the distance from the rifle to the target and
d
is the vertical drop of the bullet

at the target.