Game Development Reference
In-Depth Information
is similar to the adjustment for elevation. By turning a knob, you can adjust your scope
or sights to be slightly to the right or left of the barrel's centerline. This angle, called
gamma in our simulation, enables you to cancel out the effect of wind.
To deal with wind in the field, we require simple calculations that depend on the par‐
ticular performance of the shooter's ammunition. It may work something like this: if
the wind is blowing directly across your shot, the adjustment in inches is going to be
half the wind speed in miles per hour. Of course, there are many other rules of thumb
that differ for each caliber of ammunition, but for our simulation you can tune the wind
drag coefficient to whatever value you want your shooter to encounter. He will have to
spend some time at the range, just like a real shooter, figuring out how much the wind
affects his shots. As the wind changes, he will have to adjust in real time and either aim
to the left or right of the target or readjust the windage settings for the scope.
Breathing and Body Position
Although most games don't model gravity and wind when calculating bullet trajectories,
many do attempt to regulate the accuracy with which you initially fire the bullet. Most
commonly, game developers accomplish this by approximating the crosshairs with four
lines that do not intersect. When fired, the bullet will land anywhere within the circle
described by the inner endpoints of these four lines. Different weapons have different
accuracies, and the lines can move in or out to reflect that. Usually the first shot is the
most accurate, and once the weapon is fired you must “resight” the target, and this takes
time. Therefore, shots fired in quick succession usually become less and less accurate.
In our simulation, we modeled a few things that affect accuracy in the real world and
will give you some suggestions for other factors you could easily include. As our game
was most interested in long-distance shooting via rifles, the most common source of
error is breathing. As discussed before, when a shooter is looking through a scope on a
rifle, she essentially becomes a fixed body. As she breathes, the rifle is essentially breath‐
ing too. When making difficult shots, it is very common for the shooter to take a breath
and hold it while firing. In our simulation, we've modeled this with a breathing class
that adjusts the point of aim up and down with time to mimic how a scope moves when
the shooter is breathing deeply. This works via a timer started in our initCompo
nents() function that fires every 100 ms. In the code that follows, you'll see that this
leads to a breath every two seconds.
timer = new Timer(100, TargetPanel);
That function causes the aim point (aimX, aimY) to be moved independently of the
cursor via the following algorithm:
if (direction == true) {
breathHeight = breathHeight + 1;
if (breathHeight == 5) {
Search Nedrilad ::

Custom Search