This feature is in an experimental state so you can try it out, provide feedback, and see what we are planning. You cannot publish a project that uses Itemization at this time.
Please keep in mind that we do not guarantee backward compatibility for assets created at the experimental stage. The APIs for these features are subject to change, and we may remove entire experimental features or specific functionality at our discretion. Check out the list of known issues before you start working with the feature.
The inventory_component is a Scene Graph component used as a container for Items. For how to add a component to your entity, see Working with Entities and Components.
Entities are only considered items if they have an item_component. Without one, entities will not be added to inventories properly as well as Custom Item and Inventories functionality may be broken.
References to an “item” are referring to an entity with an
item_component.References to “inventories” are referring to an entity with an
inventory_component.
Class Description
The inventory_component is used as a container to hold items. Items added to the inventory become children of the inventory_component's entity. Along with the normal scene graph hierarchy functionality, Inventories can manage themselves and their owned items with specific properties and methods:
Add or remove items using
AddItem()andRemoveItem().To retrieve items
GetItem()andFindItems()can be used. Get functions return immediate children, whereas Find functions return all descendents.To find other inventories there is
GetInventories()andFindInventories().Events to subscribe to, such as
AddItemEventandRemoveItemEvent.GetEquippedItems()can be used for equipment, and the eventsEquipItemEventandUnequipItemEventused to track them.
With an inventory_component, any entity could become a bag or a backpack, a chest containing loot, or even a character loadout with weapons and abilities.
Inventories can control which items are added/removed in different ways. One useful method involves Scene Events. When the AddItem() function is called a scene event is broadcast that can be responded to by components. When a scene event arrives at a component, the SendDown() event is fired, which can be overridden to trigger logic. See the example Verse code on this page.
To add a component to your entity, refer to Working with Entities and Components. The component is listed as inventory_component in the component dropdown list. For more information, check out the inventory_component API reference from the Verse API.
Inventories and Scene Graph
The Custom Items and Inventories system delivers a basic setup that should be understood to get the most out of it.
All Players will begin with a Root Inventory which is an entity with an inventory_component attached to the Player Entity. This Root Inventory also has a number of fort_inventory_component sub-inventories. These are required to preserve Fortnite functionality. See Fort Inventory Component for details on these components.
Due to the method of traversing the Scene Graph, the Root Inventory will always be the first Inventory found when searching an entity tree for an entity with an inventory_component. For this reason, the Root Inventory is a sensible target to attach new Inventories.
# Helper function that gets the first descendant inventory component from an agent.
# This will be the root inventory.
GetAgentInventory(Agent:agent)<decides><transacts>:inventory_component=
TargetInventory := (for (I : Agent.FindDescendantComponents(inventory_component)) { I })[0]The Root Inventory is attached to the Player, and all the sub-inventories are attached to the Root Inventory. New Inventories should be added to the Root Inventory so that other systems only need to find and interface with the one Root inventory.
Example
Adding an inventory_component to an entity in the Prefab Editor allows it to store items as an Inventory.
The chest below has an inventory_component. It can now leverage all the functionality inside the component.
However to get the most power from Custom Items and Inventories, you will need to use Verse:
using { /Fortnite.com/Devices }
using { /Fortnite.com/Itemization }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Itemization }
# This device will give an inventory to all players
# It will then make a dummy item and give it to the inventory.
inventory_giver_device := class(creative_device) :
A common requirement of inventories is to apply rules to what items may exist inside. Below is a script for a custom inventory_component which overrides the component
method OnReceive(). Here it has been used to make a maximum Inventory size rule:
# This error can be created if the inventory is at capacity.
no_slots_add_item_error := class(add_item_error):
# This custom inventory component overrides the SendDownfunction.
# This will allow us to determine whether or not we want an entity with this inventory component, to receive items.
custom_inventory_component := class(inventory_component) :
# What is the maximum number of items allowed in this inventory?
For gameplay examples of inventories and how to use the inventory_component, see the tutorials in Custom Items and Inventories with Scene Graph.