Skip to content

Quick Start: Items and Fragments

It's time to create and add some items to our inventory. Since this a "Quick Start" chapter, we won't get too deep on the details for Items and Fragments, but you can find more information about those in the appropriate chapter.

For now, it's important to at least know that items are built using aggregation. This means that you use small pieces of data and logic to add certain aspects to an item. These pieces are called Fragments, and the framework already provides a few of them, ready to be used. As usual, you can also create your own.

Items are defined by Data Assets created from the UNinjaInventoryItemDataAsset class and in this page, we'll create a few of them exploring some different nuances. At the end, we'll assign them as default items in the Inventory Manager.

Iron Bar

Let's create an Iron Bar. We'll name our asset Crafting_Iron_Bar and once we are done, this is what is going to look to look like.

Iron Bar

Let's break down each part of this Data Asset:

First, we can add Gameplay Tags that represent this item. It's recommended to have at least one Gameplay Tag that can uniquely identify this item type.

We are not changing the Default Instance Class, but we'll add a few Fragments. You can read detais about each fragment in the appropriate chapter, but here's a quick summary of the fragments that we are adding:

Fragment Description
User Interface Information used when this item is displayed in the user interface.
Stack Defines how this item can be stacked and absolute limits that can be stored.
Container Configures how this item interacts with containers and its own containers, if any.
Quality Defines the quality for the item, based on the global Quality table.
Weight How much each item weights in the inventory.

Health Potion

Let's create a Health Potion. We'll name our asset Consumable_Potion_Health and once we are done, this is what is going to look like.

Health Potion

Once again, we set our Gameplay Tags and Container Query and we'll add some fragments. In this item, we'll add a new fragment, the Consumable Fragment.

Fragment Description
Consumable Defines how this item behaves when used by the Consume Item Ability.

Sword

Shield

Upper Body

Lower Body

Adding Items to the Inventory