Implementing an inventory system


Hi all,

In this devlog, I wanted to drive you through the process of creating an inventory system for my game. This is a technical devlog, where I explain in detail the code side of the inventory implementation. The inventory is meant to be extendible and to account for all kind of items. From the moment an item is stored, to the usage and the removal of the item, any behaviour can be defined. In this way, the inventory items can trigger any necessary action. As an example, I explain how a key item is implemented. This item is meant to open a specific door of the scene. To achieve this behaviour, I make use of the variables system too. The item has an action which is triggered when it is stored in the inventory. The action will change the variable state to true. This variable is related to the opening of the door: when it is true, the player can open the door. Whenever we remove the item from the inventory, we trigger another action which does the opposite, it sets the variable to false. Finally, since this is a single use key and can be consumed. We add another action which will trigger when we use the item.  This action will basically consume the item.  

As you can see, we can build up an item from actions happening on storage, usage and removal from the inventory. We can create incredibly complex behaviour by using this system and all items are not more than data objects holding this information.

Here you can watch a video where I explain all this in more detail.


I hope you liked the content. Please, feel free to leave a comment!

Get 3D game project

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.