Game Development Reference
In-Depth Information
4.4.2 Shooting, Hitting, Bouncing, and Stacking
The shooting, hitting, bouncing, and stacking mechanics used in computer
games are synonymous with similar mechanics that make real-world games
with a ball so popular. In order to play, players must understand the laws
of physics and how they can achieve their goals by using the physical
properties of the game environment to their best ability. For example,
10-pin bowling requires the player to toss a ball down an alleyway
constructed of polished timber with gutters on each side in order to mow
over as many pins as possible. Players must take into consideration the
weight of the ball, the speed as with they throw, the angle at which they
throw with respect to the length of the alley, and the mass of the pins.
Players adapt succeeding attempts at knocking the pins over based on past
performance. For example, if players find that they tend to always land the
ball in the right gutter, they might decide to release it closer to the left or
try to spin the ball in the opposite direction.
Many computer games implement these trial-and-error environmental
impact practices. For example, the highly successful mobile game Angry Birds
sees the player attempting to use a slingshot to hurl birds at stacked objects
in order to knock them over. The Xbox Kinect game Kinectimals also presents
the player with the same knock-over-the-stack minigames. Each time players
take a shot at something they gather feedback from their attempt based
on the number of items knocked over or the direction in which the ball (or
bird) went and how fast they were flung. Players then use this knowledge to
improve their next try.
Game engines that include physics systems such as Unity take much of the
work out of creating these types of games as developers can rely heavily on
the physics calculations doing most of the work for them. For example, the
old PC game Gorillas that saw gorillas throwing bananas across the screen
in an attempt to hit each other using a variety of trajectories had to have
the mathematics programmed directly into its base code. Today, the task
is simpler because the player can just throw an object and let the physics
system take care of the rest—well almost.
Unity Hands On
In this hands-on session you will create a simple cannon to fire
cannonballs at a stacked structure on the other side of a terrain.
Step 1. Download Chapter Four/ from the Web site.
Unzip and open the project in Unity. Open the scene called
scorchedEarth2011 . In the game you will see a terrain and a
Step 2. Create a new JavaScript file called aim.js . Enter the code
shown in Listing 4.15 . This script provides rotation to a game object
Search Nedrilad ::

Custom Search