Item Slots

The CharacterItemSlot component is an identifier component that represents the location that an item can be equipped. By default for humanoid characters the right hand represents a slot ID of 0 and the left hand represents a slot ID of 1. The Inventory component is responsible for finding the CharacterItemSlot components in the rig and store them.

The number of slots is defined by the biggest numbered ID in the list of CharacterItemSlot found in the Character hierarchy.

When the Item Set Manager determines if a particular item can be equipped it does so based off of the slot system. Think of slots like an array element within the inventory. Only one item can occupy each slot, and that item has to be unique so the inventory knows which item should be equipped. From the animator’s perspective that unique item is represented by the animator ID.

Consider the example where you want to have dual pistols equipped. In the animator the pistol items are represented by the unique animator ID of 2, but because you can have multiple pistols they should each occupy a slot within the inventory. When both pistols are equipped the animator will contain the following values:

Slot0ItemID: 2
Slot1ItemID: 2

This tells the animator that the character has dual pistols. Similarly,

Slot0ItemID: 22
Slot1ItemID: 25

Tells the animator that the sword and shield are equipped.

The Animator ID is defined on the CharacterItem component.

The demo scene is setup for two slots: slot 0 represents the right hand and slot 1 represents the left hand. The number of slots is determined by the index of the ItemSlot component. When you create your character this component is added to the “Items” GameObject underneath the character’s rig.

If your character can switch between both first and third person perspective then there should be a matching slot for each perspective. For example, if the assault rifle is in slot 0, the right hand, of the third person perspective then it should also be in slot 0, the right hand, of the first person perspective. Each perspective must have the same number of item slots in the same location.

Third Person perspective:

First Person Perspective:

The controller can handle any number of slots but the Animator is only setup to handle two slots so if you are using an animator and want to use more than two slots you’ll need to add four new slot parameters. These parameters should be (where X represents the slot index):

  • SlotXItemID (int)
  • SlotXItemStateIndex (int)
  • SlotXItemStateIndexChange (trigger)
  • SlotXItemSubstateIndex (int)

Once these parameters are setup the Animator Monitor component will automatically set the parameters based on the slot count.