How to check if the player has specific item in the inventory?

Dears,

How to check if the player has specific item in the inventory?
I am trying HasItem(), after getting a component's object from the inventory script, but it requires ItemIdentifier.
Is there a method to get the ItemIdentifier of the item by the item's name?

The problem is that the documentation refers to m_Inventoryobject, but I don't know this object should be of which type?
I tried Inventory and InventoryBase, but when I do call any method in the documentation, such as:
var equipmentItemCollection = m_Inventory.GetItemCollection(m_EquipmentItemCollectionID) as ItemSlotCollection;
It generates an error, that the method GetItemCollection not found on the m_Inventory?

Best regards,
 
In this case the Inventory is the UIS (Ultimate Inventory System) Inventory. Not to be confused with the Inventory of the CharacterController.
They are both named Inventory, so the confusion is understandable. To make sure you have the correct one, double check your "using" at the top of the script.

My assumption is that you are getting the Character Controller Inventory instead of the UIS Inventory. That's why HasItem() is asking for an ItemIdentifier instead of an Item.

Note that Item is an ItemIdentifier. But to get an item reference you'll need the UIS Inventory. Since it will allow you to get an ItemInfo from an itemDefinition.

I hope that makes sense
 
Top