top of page

Inventory System

InventoryDroping.gif
InventoryScreenShot.png
InventoryFull.gif

Overview

​The inventory system described on this page was created for Project Empathy. It was designed to enable players to store items they find during their travels and have access to them while playing the game. This system is one of the most commonly used features throughout the game and plays a crucial role in its game design. The system is primarily created using buttons, which allows players to click on specific slots to activate its usage.

Intent

The intent of this page is to provide information about the inventory system to designers. The inventory system can store any type of item with any type of use.

Creating an Item and custom usage

In order to create items, I created a scriptable object in unity or in other words data assets in Unreal engine that stores the data for each unique item.  I gave each item its own name, image, value, unique sound that plays when you use the item and droppable mesh. On the same script I added a use function so that every item will be able to call it and override their own usage.

ItemScreenShot.png
Picture2.png

Creating an Item

Designers can create their own items just by right clicking on the resource folder to create items. Then they could customize their own item properties.

Unity_QRA6yNXcNo.gif

How inventory works

UI

The inventory system is set up through the user interface. You begin by creating images that act as the inventory slots. These can be any images that the designer feels they want the empty slots to look like. Then the designer organizes them in a way that makes it look like an inventory. Each slot will have its own inventory slot script attached to it, which defines the logic of that slot. On top of the image of an empty slot, there will be a child image that is initially set to empty, but will later display an image of the item in that slot.

InventoryStill.png
InventorySlotExample.png

Inventory Script

The inventory script is the brain of the inventory system. It gathers data on every slot in the UI and has important functions such as adding and removing items from the inventory. It is also where I keep track of the item menu that spawns near the item slot to allow the player to examine, use or drop. To track the slots created in the UI, I created an array of slots for the variables.

InventoryScriptVars.png

Here is a view on how I implemented my Add Item and Remove Item functions in the inventory script. The Add Item function checks every slot and adds the item parameter to the first unfilled slot, while also checking if the inventory has reached its limit. Remove function locates the item in the slots and removes it.

AddRemoveItem.png

Inventory Slot

The inventory slot scripts track the data in the specific slot like the item and the item sprite. The script has its own functions that are used in the inventory script like Set Item() which allows the item slot to be changed to that item and Clear item() that allows the item to be cleared from the slot and turned into a slot that is completely empty.

InvenortySlotExample1.png

Item Menu 

Additionally, the inventory slot script tracks the item menu that appears when you right click the item. If the player right clicks the item slot the item menu will appear and display near the item slot.  In order to get the menu to work as intended it would have to be set up with a few buttons.

ItemMenuFirstPic.png

The buttons would have to be updated each time a new slot is clicked, and the previous menu buttons would have to be cleared of their usage by removing all listeners so that if the player clicks another item that wouldn’t use a slot they shouldn’t.

ItemMenu0.png

Buttons listed in the menu at the time of this writing include 'use,' 'examine,' and 'drop.' The 'use' button displayed in the picture below is used to consume the item. It also checks if the item is consumable, and if so, it will clear it from the inventory slot. Once the 'use' button is clicked, it should remove the button's logic so that it may allow the buttons to be used for other slots. The drop' button will spawn the item object on the ground for the player while also removing it from the inventory slot. After the button is used, it resets the buttons once again. The 'examine' button opens an additional screen that shows the item description from the item scriptable object database. Then, it resets the buttons once again.

Menu2ButtonLogic.png

Overall, the inventory system works as intended and allows the players to pick up and use items that they acquire from their adventure. This system was made using Unity engine for a project.

bottom of page