Equipping armor and weapons is a must when talking about inventory and items. There are two types of equipment, skinned and not skinned. Skinned equipment is any object that gets deformed as the player animates, such as the player’s clothes. Skinned equipment must be imported in Unity with the same rig as the Skinned Mesh Renderer it will skin to. Non-skinned equipment are the other type, such as a sword.

It is particularly hard to create an equipment system that works for all games. The system is customizable and for even more freedom it is possible to replace it with your own. The equipment system is a module which no other system depends on.

Note that the Equipment system does not take care of stat changes. Stat changes are not part of the Inventory System, they are only part of the demo. The demo shows a way of how stats can be implemented for the character. The Character Stats class takes in an Equipper in its constructor which is then used to compute the character stats at any given time. You are free to follow a similar approach.

The equipping system consists of three components: the Item Slot Collection, the Item Slot Set, and the Equipper.

Item Slot Collection

The inventory can have many Item Collections. These collections can be of any type, which means Item Collections can act differently within an Inventory. The Item Slot Collection is a subclass of the Item Collection class which allows us to specify the Item Slot Set. The Item Slot Set restricts what item and how many items can be added to it. In most cases the Item Slot Collection contains the items that are equipped within the inventory so we give it the name “Equipped” and set its purpose to “Equipped”. It is important to set a unique name and purpose within the Item Collections contained in inventory. This is because the Equipper component will access the Item Collection by the name or purpose.

When an item is added to a Item Slot Collection it is first checked to ensure the item can be added to a slot. If it can then that slot is checked to determine if it is empty or occupied. If it is empty then the item can be added without a problem. If the slot is occupied then the existing item is replaced by the newly added item. The removed item will then be placed in the Main Item Collection of the Inventory.

Item Slot Set

The Item Slot Set is a Scriptable Object used to define a set of item slots. A lot of RPGs have item slots for the head, right hand, left hand, chest and leg. But not every project is the same and you may want more or less slots. You can set the slots from the inspector. Item Slots are defined as a Name, an Item Category and a size limit. You can have as many or as little as you need.

As an example consider the Right Hand slot which is defined with a Weapon Item Category and a size limit of 1. In this scenario you are allowed to equip one weapon in your right hand.

Equipper

The Equipper is used to spawn and visually equip the items within the “Equipped” Item Collection. When specifying the Item Slot set, the Equipper will allow you to specify if an Item Object slot is skinned or not, and if not where the equipped item should be spawned. You can also set the GameObjects that should be hidden when something is equipped in that slot

As you can see the equipment system is quite simple and it is independent from the Usable Item Objects or character stats. This makes it very easy to extend or completely swap out for something that fits your game requirements.