Chapter 4. Inventory

In this chapter, we will create an inventory storage system. We'll also create a GUI representation of the inventory for the player to interact with, as well as showing the player their quick items. Items that can be quickly used or equipped using easy access keys are known as quick items; they are used frequently in RPG and FPS games. Inventories are used in many games from all genres, so having a good way to make one is very helpful.

In this chapter, we will cover the following topics:

  • Creating a storage system for GameObjects
  • Adding items to the inventory
  • Removing items from the inventory
  • Initializing the inventory
  • Setting the inventory size to be dynamic
  • Making it possible to have multiples of items
  • Setting quick items that can be used by our custom quick item inputs
  • Accessing the inventory using our custom inventory inputs
  • Displaying the inventory on screen via GUI

Features of an inventory

Before creating an inventory, you must figure out what kind of inventory fits your game best. There are various features that an inventory has that will need to be figured out when designing one. The following are the features that we will discuss:

  • Limits
  • Accessibility
  • Order

Limits of the inventory

There are two common ways to limit an inventory; they are weight and slot size. If an inventory is based on weight, it will only carry a certain number of objects that are within its weight bearing limits. If an inventory is based on slot size, the player can have as many objects as long as there are slots and the weight of an object either doesn't matter or isn't tracked at all.

An example of a weight-limited inventory is found in games such as The Elder Scrolls V: Skyrim. The player can keep items in their inventory up to a certain accumulated weight limit. An example of a slot size limited inventory is found in games such as Borderlands. In Borderlands, the player's backpack is set to a certain number of slots where they can keep items; if the limit is reached, the player can't pick up any more items.

There is a third way to limit inventory, which is to combine the slot size method with the weight method. An example of this combination method is Baldur's Gate 2. In this game, the player has a backpack with multiple slots, but also a weight limit. So they may at times reach the weight limit in the inventory, but still have slots open in the inventory. Alternatively, they can reach the slot size limit of the inventory but still be holding less than the maximum weight limit.

Accessing the inventory

To access the inventory, you, as the designer, have a few options to choose from. Some of the more common ways to allow the player to access the inventory are a menu system, quick-items, and an item bar. You can also combine any or all of these methods to allow to the player to utilize the inventory in dynamic ways.

In a menu-based inventory, when the player presses a key on their keyboard or a button on their gamepad, they are taken out of the gameplay to the inventory menu. Depending on the game, this can be a single menu showing their entire inventory, or a menu broken up into submenus to organize their items.

When a quick-item method is used to access the inventory, the player just presses a key or button and their item is instantly selected. For some games, this item might need to be assigned first in an inventory menu, or in some games it may be predefined as to which item is assigned to which key or button.

If you create a game where the player will need to use a lot of items and you don't want them to open a menu stop the gameplay, then an item bar might be what you need. An example of an item bar can be seen in Massive Multiplayer Online games such as World of Warcraft. This is where the player has a GUI-based bar with button slots to hold items, spells, abilities, and so on. What each of the buttons does can be customized by the player so that they can get full control over and access to their favorite or most used items without having to use a menu to access them.

Organizing an inventory

The items within an inventory can be organized in a few ways depending on the physical size, item type, slot size, or alphabetical order. Organization by physical size can be either lightest to heaviest or heaviest to lightest. When organizing by item type, healing items should be kept separate from weapons and armor. These separate item types can be split up into multiple submenus: one each for weapons, armor, healing items, and so on.

Organization by slot size can be seen in games such as the Diablo series, where the items vary in slot size both vertically and horizontally. The player must move items around in their inventory to make room for other items. The last method of organizing items in the inventory, as mentioned previously, is alphabetically. This will show items by names from the beginning of the alphabet or from the end.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.187.62