Inventory Experiment

This was a short experiment I did over a couple weeks to see if I could implement an inventory system, which was developed into a networked inventory system.

The product was a system that let you pick-up, split, stack and drop items, to be used in an RPG style game with an inventory. 

GIF from the inventory experiment, the player is collecting items.

Inventory

Many beginner grid based inventories I saw online contained the item data on the UI itself, which is something I knew I wanted to avoid since this makes managing, saving and verifying player's inventories much harder, and if the UI gameobject is destroyed, the data would be lost.

Each player contains an inventory script which is an array of items which are managed by the UI, which is created to reflect the size and contents of the inventory.

Pickups

Items can be picked up off the floor and are automatically stacked into the players inventory, if the max stack size for that item is reached, it will roll over into the next available slot.

The player collecting an item in an older version of the inventory experiment.
GIF from the inventory experiment of players exchanging items.

Networking

In the experiment players are able to trade items with each other which operates over a network using the multiplayer package Mirror, as Netcode for Gameobjects was not yet released. Obtaining items is done server side, so players cannot obtain items illegally and all players experience the same behaviour. Spawning items from the players inventory over a network was particularly challenging.