In the Custom Items and Inventories system, an item_component becomes a class that defines what an item is and isn’t. Refer to Working with Entities and Components for how to add a component to an entity.
Entities are only considered items if they have an item_component. Without one, entities will not be added to inventories properly and lots of Custom Item and Inventories functionality may be broken.
References to an “item” are directly referring to an entity with an
item_component.References to “inventories” are directly referring to an entity with an
inventory_component.
Class Definition
Attaching an item_component to an entity turns the entity into an item. Items have a number of properties that can be leveraged by other components:
They can be manipulated by inventories.
Picked up and dropped.
Items may be equipped and unequipped.
More functionality can be given to an item with additional components that expose different features and basic Fortnite gameplay. You can also write your own custom Verse components. For more information check out the item_component API reference from the Verse API.
See Components for a complete list of Custom Items and Inventories components.
By giving an item_component to this prefab, it can now be stored as an item inside an inventory.
Verse: Items
The item_component contains fields, functions, and events to make use of through Verse.
GetParentInventory[]- Provides a way for items to identify their parent inventory.
Categories- An array ofitem_categorythat can be used to sort and characterize.Equip(),Unequip(), andIsEquipped[]- These functions help to manage the item's equipped state.ChangeEquippedEvent- This event fires on an item component whenever Equip() or Unequip() are called.ChangeInventoryEvent- Monitor items moving between inventories.
Example
Item components are required by entities to function as items. The Prefab editor has limited editable properties, so to get the most out of the component you will need to use Verse.
using { /Fortnite.com/Devices }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Itemization }
# This device will create an item for all players when they are added to Playspace. Once the item is created it will pick itself up to the Player's inventory.
item_giver_device := class(creative_device) :
Functionality can easily be added to Items by subclassing the item_component. Subclassing can modify the basic properties, or add new functions and fields specific to your experience.
using { /UnrealEngine.com/Itemization }
using { /Fortnite.com/Itemization/FortniteItemCategories }
custom_item_component := class(item_component) :
# We could populate the Categories array with Fortnite and/or custom item categories.
#For example here, we are using the Resource item_category type.
Categories<override>:[]item_category = array{Resource}