Failure to Equip from Inventory

mdonatelli

New member
Hello again,

I've been following along with the Ultimate Inventory System Integration Part 1+2 videos and am running into an issue at about the 43:10 mark of the first video.

The system I want is that you equip a weapon via your inventory. I have set up so many of the elements: The Item Categories+Definitions, the UI actions, and the Item itself in accordance with the tutorial.

However, when I try to equip the Pistol from the inventory, I get this error:

Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge.MoveItemToEquippable (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, System.Int32 equippableCollectionIndex, System.Int32 slotIndex) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/CharacterInventoryBridge.cs:349)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge.MoveEquip (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, System.Int32 equippableItemCollectionSet, System.Int32 slotID, System.Boolean equip) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/CharacterInventoryBridge.cs:457)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge.MoveEquip (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, System.Boolean equip) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/CharacterInventoryBridge.cs:443)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterEquipUnequipItemAction.InvokeActionInternal (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, Opsive.UltimateInventorySystem.ItemActions.ItemUser itemUser) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/InventoryItemActions/CharacterEquipUnequipItemAction.cs:76)
Opsive.UltimateInventorySystem.ItemActions.ItemAction.InvokeAction (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, Opsive.UltimateInventorySystem.ItemActions.ItemUser itemUser) (at Assets/Opsive/UltimateInventorySystem/Scripts/ItemActions/ItemAction.cs:97)
Opsive.UltimateInventorySystem.UI.Panels.ActionPanels.ItemActionPanel.InvokeActionInternal (System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ActionPanels/ItemActionPanel.cs:66)
Opsive.UltimateInventorySystem.UI.Panels.ActionPanels.ActionPanel`1[T].InvokeAction (System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ActionPanels/ActionPanel.cs:119)
Opsive.UltimateInventorySystem.UI.Panels.ActionPanels.ActionPanel`1+<>c__DisplayClass13_0[T].<OpenInternal>b__0 () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ActionPanels/ActionPanel.cs:69)
Opsive.UltimateInventorySystem.UI.CompoundElements.ActionButton.Press () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/CompoundElements/ActionButton.cs:72)
Opsive.UltimateInventorySystem.UI.CompoundElements.ActionButton.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/CompoundElements/ActionButton.cs:123)
UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at D:/Dev/Tools/Unity/2020.3.3f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at D:/Dev/Tools/Unity/2020.3.3f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:262)
UnityEngine.EventSystems.EventSystem:Update() (at D:/Dev/Tools/Unity/2020.3.3f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:385)

It happens at the moment I choose the Equip action on the Item in the inventory.

Weapon1.png

My item definition has the proper prefabs. 1) the Prefab created for the item via the tutorial steps, and 2) a simple prefab that is just a game object with the 3d mesh for the drop visualization. I also went through the Item Binding steps using the Integrations window.

Weapon2.png

Weapon3.png

I've rewatched several times and am at a loss for what I'm missing and what could be null on what prefab. Any direction or places to look would be greatly appreciated. Hopefully, I'm just missing something and it's not a bug.
 
I just found a warning that said this:

Code:
Error: Unable to find the collection with name Default.
UnityEngine.Debug:LogWarning (object)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge:GetItemCollection (string,bool) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/CharacterInventoryBridge.cs:164)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge:Awake () (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/CharacterInventoryBridge.cs:122)

Seems very relevant, looking into this.
 
Ok, one thing I was missing was an Item Collection on the Player prefab. I set that up in the character manager, but the warning persists.
Character.png
 
Figured it out! The Inventory Bridge component on the Player prefab indicated "Default" for the Default Item Collection. Whereas the Inventory component on the player had a collection named Main, not Default. This solved my warning and the inability to Equip the created Weapon.

InventoryBridge.png

Inventory2.png
 
Great, I'm glad you were able to find and fix your issue.
The ItemCollection should have been named default when following the tutorial step by step, I wonder why it wasn't the case for you.

I'll rephrase the warning message to make it clrearer
 
The ItemCollection wasn't named Default because the Player character prefab was set up by a team member not following the tutorial initially. Not an error of the tutorial! Thanks for checking in.
 
Top