Devlog 6: Player Inventory


This week, I was working on adding the player's inventory into the game. The first part of adding the player inventory was to make an item database to store the items in the game. The item database will be used by the player inventory and the crafting system to make sure that the player gets the correct items. After the item database was added I moved on to adding the inventory script. The script is the main part of the inventory system, it keeps track of the items in the inventory, and it updates the inventory UI. The inventory script has functions to add and remove items from the player inventory. The items pickups will call the function to add the item to the inventory when the player picks up an item.

After I had the functionality of the inventory done, I moved on to the inventory UI. I started with making the inventory panel and then I added a grid layout to store the inventory slots. I created a tooltip to give the player some information about the items in the inventory and I created a menu that appears when the player presses the right mouse button, the menu allows the player to equip, use or drop items. The last part of the inventory was to open and close the inventory when the player presses the 'I' key. I started by making a key binding called 'Inventory', then in the player controller, I made a function that is called when the player presses the 'I' key. If the inventory is on the screen the game will stop the player from moving. The player can close the inventory screen by pressing the 'I' key and they will be able to move again.