Game Development Reference
In-Depth Information
6.4 Inventories
Inventories are a game mechanic that spans numerous game genres. Basically
they are a list of items players have in their possession. In The Sims , each Sim
has an inventory of items such as topics, food, and other objects they can
take with them to different locations. If a Sim is required to deliver a parcel,
it is added to their inventory. When they arrive at the parcel's destination, it
is removed. In Splinter Cell , the player's character Sam Fischer carries quite
an arsenal around with him.
Inventories can be a fixed size, allowing only a finite number of items or
infinite items. In the Dungeons and Dragons classic title Eye of the Beholder ,
characters could only carry several items. In order to take on another item,
the player had to decide which item to discard to make way for the new
one. This inventory size restriction adds a new mechanic all of its own where
players must preference the items they have. In Doom , the player could have
up to six weapons (each switchable with the keys 2-7 on the keyboard),
whereas in Halo , if Master Chief picks up a weapon, the current weapon is
thrown away (with the exception that sometimes he can brandish a gun
in each hand).
One example of a very complex inventory is the one players have in EVE
Online . Players can have multitudes of ships, minerals, ship parts, and
blueprints in their possession. And these aren't all in the same location.
Minerals and parts can be on ships and ships can be docked on different
planets. It is quite a feat of logistics to manage the location of items
and ships to facilitate the most efficient game play.
In the following workshop you will create a Doom -like scenario with a user
interface and fixed size inventory in which the player collects colored keys
to open the same color doors.
Hands On
Step 1. Download and open Chapter Six/ Open the
file in Unity and open the scene called maze . Play. The Unity default
third person avatar will appear in front of a large red door. This door
is the entry to the maze. The player will need a red key to open the
Step 2. There is a key model in the Project. Add it to the hierarchy and
position it on the ground somewhere near the avatar but far enough
away that the player will have to walk over to it. Change the material
color to make the key red. Change the name of the key instance in the
Hierarcy to RedKey .
Step 3. Create a new tag called key. Give RedKey this tag.
Step 4. Add a box collider to the RedKey.
Step 5. Create a new JavaScript file called pickup. Add the code shown
in Listing 6.4 .
Search Nedrilad ::

Custom Search