Inventory
Adding Inventory Items
Open or create a new Inventory Database asset. In the desired folder, right-click and select Create -> UHFPS -> Game -> Inventory Database.
To open the Inventory Builder window, double-click the asset or click the Open Inventory Builder button.
In the Inventory Builder window, click on the plus (+) button located on the left side near the Inventory Items label to add a new section.

To add a new item, right-click on the section and select Add Item.

Define the amount of space that an item will take up in the inventory by adjusting the Width and Height slider in the Item Grid View.



If you have created a new Inventory Database, assign it to the Inventory component located in the GAMEMANAGER object.

To pickup your newly created item to the in-game inventory, change the layer of the object to Interact and add the Interactable Item component to it. Then, change the Interactable Type to Inventory Item and assign the pickup item with your item.


To access the custom data, you just need to have a reference to an InventoryItem that represents the item in the inventory. To get that reference, call the GetInventoryItem function from the Inventory component.
Here's the code snippet for that:
You can also have nested JSON data that you can access using the JObject reference:

To change a JSON property value, use the JObject reference directly, but instead of casting the value to a type, simply set the value. After changing the values, use the Update() function to save the changes in the custom data.
Inventory Item Selector
To open the Inventory Item Selector, derive from the IInventorySelector interface and call the OpenItemSelector() function on the Inventory component.
Here's a code snippet to open the item selector:
Combinable Items
To define an item as a combinable item, enable the Is Combinable toggle in the item settings.

Go to the Combine Settings and add new combinations.
To trigger the combine event on the player item after combining it with another item, enable the Event After Combine toggle.

The combine event will only trigger on the second item, so you have to make the combination for example from Battery -> Flashlight.
Also make sure that the second item (Flashlight) is Usable and the Usable Type is Player Item.
In the player item script that derives from the PlayerItemBehaviour, override the CanCombine() and OnItemCombine() functions.


Last updated