The inventory classes within version 2.2 has been refactored in order to support our upcoming inventory system. While the inventory system is a standalone asset that does not require the character controller, the character controller is sharing a few classes with the inventory system in order to make a seamless integration. As a result of these changes, there are few steps required in order to update to version 2.2 from a prior version.

Import

After importing version 2.2 into your project a dialogue will appear which checks for the basic requirements:

The following checks are performed:

  • Located Install Package: When version 2.2 is imported both the installer and a separate package is imported. This separate package contains the character controller assets.
  • Unity 2018.4 or Newer: Unity 2018.4 is now the minimum version. If you are running a prior version you’ll need to first install 2018.4 or newer.
  • .NET 4.x Scripting Runtime: The scripting runtime has been updated and now uses .NET 4. Version 3 of the framework has been deprecated and can be changed within the Unity Player Settings.
  • Clean Install: Version 2.2 moves/removes many files and Unity Packages do not deal well with these type of changes. As a result the entire Opsive/UltimateCharacterController directory should be removed before version 2.2 isĀ installed. Ensure you have first moved your own assets out of that folder and have a backup.

Assuming all of these requirements are satisfied you can click Install to import version 2.2. The Opsive/Installer folder can then be removed.

2.2 Setup

After version 2.2 has been installed the following changes are required:

Inventory Category

The class for the inventory categories has changed for version 2.2. Any created categories should be created within the Item Type Manager.

Item Type Category Assignment

After the category has been created it should be reassigned to the Item Type.

Item Set Manager

Assign the created categories to the Item Set Manager.

Item Ability Category Assignment

The new categories should be assigned to theĀ ItemSet Category field of the Item Set Item Abilities. This will need to be done for each Item Ability: Equip Unequip, Toggle Equip, Equip Next, Equip Previous, and Equip Scroll.

Default Loadout

The Item Type Count class has been renamed to Item Definition Amount. As a result the Amount within the Inventory’s Default Loadout must be updated.

Item Pickup

Similar to the Default Loadout, the Amount field within the Item Definition Amounts on the Item Pickup field must be updated.

Ability Allow Item Definitions

The Allow Item Definitions under the Ability’s General tab must be updated with the Item Types.

Append Item

The Append Item field needs to be updated. This fields append the Item Definition’s name to the state name and is most commonly used for the Aim ability.

Pickup Item

If you’re using the Pickup Item ability the Pickup Item Definitions need to be updated.

Drop Item

If you’re using the Drop Item ability the No Drop Item Definitions need to be updated.

Slot Equip

If you’re using the Slot Equip ability with the VR Add-On the Default Item Definitions and Item Definition State Names arrays need to be updated.

Repeated Jump

If you’re using a Repeated Jump for the Jump ability the field has been renamed to Airborne Jump. These values will need to be updated with the new name.

Nolan Rig

The Nolan rig has been reexported using Blender 2.8. Due to this change the previous Nolan character will no longer work with the model included in version 2.2. If you’re using Nolan in your own scene you’ll need to recreate the character.

Namespaces

Many common classes are shared between the character controller and inventory system. These files are in a new “Shared” namespace. The follow commonly used classes were changed:

Opsive.Shared.Events
  • Event Handler
Opsive.Shared.Game
  • Game Object Extensions (responsible for GetCachedComponent)
  • Object Pool
  • Scheduler
Opsive.Shared.Inventory
  • IItemIdentifier (formally Item Type)
  • ItemDefinitionBase
Opsive.Shared.Utility
  • Generic Object Pool (used to be within Object Pool)
  • Type Utility (for GetType)

API

The API underwent changes during the version 2.2 update. Most of the changes were for the new inventory system structure.

Inventory

ItemTypeCount has been renamed to ItemDefinitionAmount, with Amount being an int instead of a float.

AddItem has a new parameter:

/// <summary>
/// Adds the item to the inventory. This does not add the actual ItemIdentifier - PickupItem does that.
/// </summary>
/// <param name="item">The Item to add.</param>
/// <param name="immediateEquip">Can the item be equipped immediately?</param>
/// <param name="forcePickup">Should the item be force equipped?</param>
void AddItem(Item item, bool immediateEquip, bool forceEquip)

PickupItemType has been renamed to Pickup with updated parameters:

/// <summary>
/// Adds the specified amount of the ItemIdentifier to the inventory.
/// </summary>
/// <param name="itemIdentifier">The ItemIdentifier to add.</param>
/// <param name="amount">The amount of ItemIdentifier to add.</param>
/// <param name="slotID">The slot ID that picked up the item. A -1 value will indicate no specified slot.</param>
/// <param name="immediatePickup">Should the item be picked up immediately?</param>
/// <param name="forceEquip">Should the item be force equipped?</param>
/// <returns>True if the ItemIdentifier was picked up.</returns>
bool Pickup(IItemIdentifier itemIdentifier, int amount, int slotID, bool immediatePickup, bool forceEquip)

GetItem has been renamed to GetActiveItem:

/// <summary>
/// Returns the active item in the specified slot.
/// </summary>
/// <param name="slotID">The ID of the slot.</param>
/// <returns>The active item which occupies the specified slot. Can be null.</returns>
Item GetActiveItem(int slotID)

GetItem now uses an IItemIdentifier instead of ItemType:

/// <summary>
/// Returns the item that corresponds to the specified ItemIdentifier.
/// </summary>
/// <param name="slotID">The ID of the slot which the item belongs to.</param>
/// <param name="itemIdentifier">The ItemIdentifier of the item.</param>
/// <returns>The item which occupies the specified slot. Can be null.</returns>
Item GetItem(int slotID, IItemIdentifier itemIdentifier)

EquipItem has an updated parameter:

/// <summary>
/// Equips the ItemIdentifier in the specified slot.
/// </summary>
/// <param name="itemIdentifier">The ItemIdentifier to equip.</param>
/// <param name="slotID">The ID of the slot.</param>
/// <param name="immediateEquip">Is the item being equipped immediately? Immediate equips will occur from the default loadout or quickly switching to the item.</param>
void EquipItem(IItemIdentifier itemIdentifier, int slotID, bool immediateEquip)

UnequipItem has an updated parameter:

/// <summary>
/// Unequips the specified ItemIdentifier in the specified slot.
/// </summary>
/// <param name="itemIdentifier">The ItemIdentifier to unequip. If the ItemIdentifier isn't currently equipped then no changes will be made.</param>
/// <param name="slotID">The ID of the slot.</param>
void UnequipItem(IItemIdentifier itemIdentifier, int slotID)

GetItemTypeCount has been renamed to GetItemIdentifierAmount with an updated parameter:

/// <summary>
/// Returns the amount of the specified ItemIdentifier.
/// </summary>
/// <param name="itemIdentifier">The ItemIdentifier to get the amount of.</param>
/// <returns>The amount of the specified ItemIdentifier.</returns>
int GetItemIdentifierAmount(IItemIdentifier itemIdentifier)

UseItem has been renamed to AdjustItemIdentifierAmount with updated parameters:

/// <summary>
/// Adjusts the amount of the specified ItemIdentifier.
/// </summary>
/// <param name="itemIdentifier">The ItemIdentifier to adjust.</param>
/// <param name="amount">The amount of ItemIdentifier to adjust.</param>
void AdjustItemIdentifierAmount(IItemIdentifier itemIdentifier, int amount)

RemoveItem has an updated parameter:

/// <summary>
/// Removes the ItemIdentifier from the inventory.
/// </summary>
/// <param name="itemIdentifier">The ItemIdentifier to remove.</param>
/// <param name="slotID">The ID of the slot.</param>
/// <param name="drop">Should the item be dropped when removed?</param>
void RemoveItem(IItemIdentifier itemIdentifier, int slotID, bool drop)
Ultimate Character Locomotion

AddSubCollider(s) has been renamed to AddIgnoredCollider(s):

/// <summary>
/// Adds an element to the ignored collider array.
/// </summary>
/// <param name="collider">The collider which should be added to the array.</param>
void AddIgnoredCollider(Collider collider)

/// <summary>
/// Adds an array to the ignored collider array.
/// </summary>
/// <param name="colliders">The colliders which should be added to the array.</param>
void AddIgnoredColliders(Collider[] colliders)

RemoveSubCollider(s) has been renamed to RemoveIgnoredCollider(s):

/// <summary>
/// Removes the specified collider from the ignored collider array.
/// </summary>
/// <param name="collider">The collider which should be removed from the array.</param>
void RemoveIgnoredCollider(Collider collider)

/// <summary>
/// Removes the specified colliders from the ignored collider array.
/// </summary>
/// <param name="colliders">The colliders that should be removed.</param>
void RemoveIgnoredColliders(Collider[] colliders)
Generic Object Pool

ObjectPool.Get and ObjectPool.Return have been moved to GenericObjectPool.Get and GenericObjectPool.Return. These are located within the Opsive.Shared.Utility namespace.