InventorySetup
Last modified: 02 September 2024Install the Ninja Inventory plugin using the Epic Games Launcher.
Open your project and enable the plugin:
Edit
→Plugins
, search for inventory, and tick the checkbox for Ninja Inventory. Restart the engine.Add
NinjaInventoryManagerComponent
to your Character or Player State. The actor must also implementAbilitySystemInterface
.Add
InventoryManagerProviderInterface
to the same object that has the Inventory Manager. Implement theGetInventoryManager
function.Add
NinjaEquipmentManagerComponent
to your Character, regardless of where the Inventory Manager was placed.Add
EquipmentManagerProviderInterface
to your character. Implement theGetEquipmentManager
function.
This page will walk you through the pre-requisites and steps necessary to enable the Ninja Inventory plugin.
Installing the Plugin
Once acquired, the plugin can be installed via the Epic Games Launcher. As with any Code Plugin, it can be installed to any compatible engine version.
Once installed, create or open your project and navigate to Edit and then Plugins. In the search bar, type inventory and the Ninja Inventory plugin should appear. Tick the checkbox and restart the engine.
C++ Libraries
If you plan to work with C++ and use classes from the Inventory System, ensure you add the following modules to your Build.cs
file:
PublicDependencyModuleNames.AddRange(new []
{
"CommonUI",
"GameplayAbilities",
"GameplayTags",
"GameplayTasks",
"InputCore",
"ModelViewViewModel",
"NinjaInventory",
"NinjaInventoryCore",
"NinjaInventoryEquipment",
"NinjaInventoryGameplay",
"NinjaInventoryUI",
"StructUtils",
"UMG"
});
Asset Manager
The Inventory System uses Primary Data Assets and soft references to load and unload assets that should only be available when certain items or equipment are obtained.
You can register these assets in the following ways:
In the Editor, configure the Asset Manager:
Edit
>Project Settings
>Asset Manager
.If you use a Modular Game Feature to add your Inventory, you can register these assets in your Feature configuration.
Asset Name | Base Class | Description |
---|---|---|
|
| Defines the data structure for Inventory Containers. |
|
| Defines the data structure for Items and Fragments. |
|
| Defines the data structure for Equipment. |
|
| Default Skeletal Meshes for unused Equipment Slots. |
Once configured, your entries in the Asset Manager should look like this:
tip
Asset Directory
If you have a specific directory for your Data Assets, like in the example above, make sure to set that in the Primary Asset type registry as well.
Ability System
The Ability System Component is a prerequisite for the system to operate. Ensure that actors using the Inventory Manager Component also have an Ability System Component and implement the AbilitySystemInterface
.
If you are using the Inventory Attribute Set, add it along with the appropriate initialization data. Also, review the Abilities to learn more about abilities that should be granted by default.
Inventory Manager
The Inventory Manager is the primary component that must be added to any actor with an inventory.
The Inventory Manager can be added to a Player State or Pawn. Both are equally viable and the decisive factor should be your inventory's persistence. The Player State is usually a good option for inventories that should be kept over respawns or level travel.
During its initialization, the Inventory Manager will wait for the Ability System Component to initialize and obtain an avatar that is not a Player State.
tip
The Inventory Manager always waits for the Ability System Component to replicate before it can fully initialize.
If this step results in a timeout, you will find a warning in your log under the LogNinjaInventory category.
[NinjaInventoryLog] UNinjaInventoryAction_WaitForAbilitySystem: Waited 3s for the required object. Giving up...
Inventory Provider Interface
After adding the Inventory Manager to the appropriate actor, the next step is to add the InventoryManagerProviderInterface
and implement the GetInventoryManager
function to return the component.
Equipment Manager
The Equipment Manager is not a mandatory component but will likely be added to any actors using items with a physical presence in the game world.
Similar to the Inventory Manager, the Equipment Manager also has a prerequisite for its initialization, requiring the Inventory Manager to be replicated and initialized.
tip
If this step results in a timeout, you will find a warning in your log under the LogNinjaInventory category.
[NinjaInventoryLog] UNinjaInventoryAction_WaitForInventoryManager: Waited 3s for the required object. Giving up...
The Equipment Manager must be added to the actual Pawn, regardless of where the Inventory Manager was added.
Equipment Provider Interface
After adding the Equipment Manager to the appropriate pawn, the next step is to add the EquipmentManagerProviderInterface
and implement the GetEquipmentManager
function to return the component.