Items & Inventory

The focus of the Ultimate Character Controller is to be an exceptional character controller so the inventory system is not as feature rich as other solutions, its focus is on being flexible. With that said, the function of the Inventory is to keep track of items owned (weapons, ammo, etc…) such that the character can equip and use items.

The inventory uses Item Definitions to identify a particular item. Item Definitions are also used for consumables such as assault rifle bullets or amount of battery left. The built-in inventory class uses a concept of Item Types, which are a subclass of Item Definitions. You’ll also see Item Identifiers within the asset and these are a reference to the specific item instance. This distinction is made to allow for easier integration with our inventory solution asset. Item Types are used within the character controller and are both Item Definitions and Item Identifiers. Item Types can be created within the Item Type Manager.

Getting started

The Character Controller comes with the ability to add, equip and use items. This requires a few components, the main ones are:

  • Inventory: a component that keeps track of what items the character has, including non character items like ammo.
  • Item Set Manager: The component that manages what items can be equipped, in which hand and with what combinations using rules. For example allow sword and shield to be equipped at the same time, but not assault rifle and shield.
  • Character Item: GameObject that your character can equip/unequip and drop.
  • Item Actions: Character Items can have multiple Item Actions to give Items functionality, such as Shootable Action or Melee Action.
  • Item Pickup: A GameObject that allows the character to pickup an item using an input or by trigger enter.

The supported features are:

  • First / third person view items (depending on the version of the character controller you own you may only have one of those).
  • Equip multiple items at once in combinations defined by your own rules.
  • Keep track of items the character owns including ammo.
  • Use character item actions to shoot, attack or cause chain reactions with magic.
  • Change values on the Character Item with the state system.
  • Independent Animated Character Items.
  • Full and partial body animation for Character Items.

Out of scope features:

  • Inventory User Interface
  • Multiple unique items with dynamic stats per ItemDefinition.
  • Inventory size limitations.
  • Cloth / character skinned mesh items.
Check out the Ultimate Inventory System if you are interested in any of these features. The integration takes into account all those features and much more.

Terminology

  • Inventory: The Inventory keeps track of the items the character owns.
  • ItemSet Manager: The component that manages what items can be equipped, in which hand and with what combinations using rules. For example allow sword and shield to be equipped at the same time, but not assault rifle and shield.
  • Item Set: Item Sets are objects that contain information about what items can be equipped together. When active it can also set some states such that any state object can know that this specific combination of items are equipped.
  • Item Set Group: Having multiple Item Set Groups allow multiple item sets to be active at the same time. This is useful when using items that are used in parallel with your default item set (Example: Use a grenade while using an assault rifle, or a magic item while having a sword and shield equipped).
  • Item Set Rule: The Item Set rules are what creates ItemSets depending on a set of simple rules. This is much faster to set up than manually adding item sets for all possible item combinations. (Example: Set a rule that creates an ItemSet for all magic items with the magic item in slot 3).
  • Item Definition (a.k.a Item Type): a ScriptableObject that contains the name and prefabs related to the item.
  • Item Identifier: an interface for item instances when there can be multiple item references for a single ItemDefinition.
  • Character Item: This component defines the gameobject that is used as the item for the character
  • First Person Perspective Item: The component used to define what visuals are used for when the character is in third person view.
  • Third Person Perspective Item: The component used to define what visuals are used when the characters are in first person view.
  • Character Item Action: Character Item actions are components set on the Character Item GameObject which are used to define how the Character Item can be used. For example: Shootable Action, Melee Action, Shield Action, Magic Action are all Character Item Actions.
  • First Person Objects: Manages the location of the first person objects while in first or third person view.
  • Item Ability: Item Abilities are abilities that the character can use on items. For example Equip Unequip, Use, Aim, etc. These can be set with blocking and priority such that different inputs or states can trigger an ability which can in turn do something on the Character Item. The Use ability is often used for Character Item Actions.