# Video Game Bow and Arrow Mechanics

#### Wretch11

I'm trying to implement bow and arrow mechanics in a game. Considering that I know two points on a grid, a launch angle, a velocity and the gravitational constant, how would I go about calculating an arrow's trajectory.

Additionally, how would I go about calculating the arrow's angle along every point of it's trajectory arc?

EDIT: I meant to post this in the kinematics sub-forum. Would be much obliged to the mods if this got moved to the appropriate place. Apologies for the hassle

Thank you.

Last edited:

#### ChipB

PHF Helper
I assume what you mean by "trajectory" is you need formulas for x- and y-coordinates as functions of time, and same with the angle, correct?

If we ignore air resistance, then given initial velocity V_0, the horizontal velocity is $$\displaystyle v_x = V_0 \cos (\theta )$$, where $$\displaystyle \theta$$ is the launch angle. Notice that this is constant. The vertical velocity changes with time as gravity causes the arrow to decelerate, and is $$\displaystyle v_y = V_0 \sin (\theta )- gt$$ where g is the acceleration dues to gravity: $$\displaystyle g = 9.81 \frac m {s^2}$$. If the (x,y) coordinate of the launch point is $$\displaystyle (X_0,Y_0)$$, then the x- and y-positions as a function of time are:

$$\displaystyle x(t) = X_0 + V_0 \cos (\theta) t$$
$$\displaystyle y(t) = Y_0 + V_0 \sin(\theta) t - \frac 1 2 g t^2$$

The angle of the arrow to the ground is equal to the arc tangent of the vertical velocity divided by the horizontal velocity (this assumes that the arrow always points in the direction of travel, which is not absolutely correct, but should be close enough for your purposes):

$$\displaystyle \alpha = \tan^{-1} ( \frac {v_y}{v_x} ) = \tan^{-1} ( \frac {V_0 \sin (\theta )- gt}{V_0 \cos (\theta)} )$$

Last edited:

#### Woody

How accurate do you need to be?

If you require greater accuracy, or are "shooting" long distances, then the aerodynamic drag on the arrow might become important.

Do you want to include wind effects?

If all you require is that it "looks" correct, then some approximations can be made (which will allow quicker computation).
Most games adopt approximations, which will be completely un-noticeable in normal game usage, trading absolute accuracy for improved frame rates.