Configure the Inventory
To create our secondary weapon, we should have Ninja Inventory configured. So this is our next task: perform the setup, update the Weapon Manager, and convert our weapons into Items and Equipment.
Add the Inventory Attribute Set
Create a Data Table for Inventory Attributes, using the base data from Gameplay Attributes.
Change the initial Backpack Attribute to
20
, or any other value that you prefer.Add the Inventory Attribute Set to the player, via the Ability Definition.
Configure the Equipment Manager Component
Add the Equipment Manager Component to the Player Character.
Implement the Equipment Provider Interface to the Player Character and implement the
GetEquipmentManager
function.In the Equipment Manager, create two virtual slots for the weapon actors, one for the sword, one for the shield.
These Slots will be identified by the Gameplay Tags
Equipment.Slot.Weapon.MainHand
andEquipment.Slot.Weapon.OffHand
. In this example they are mapped tosWeaponMainHand
andsWeaponOffHand
sockets.
Create Equipment Actors and Definition
Re-parent your base Weapon Class or Blueprint to
ANinjaCombatEquipmentWeaponActor
.Add the
EquipmentActorInterface
to the base class. You do not need to implement any methods from this interface.Create a new Equipment Definition, from the Content Menu, for the Sword and Shield. Be sure to create this Data Asset in the folder configured in the Asset Manager.
Add a new State Configuration for the
Equipment.State.Activated
state. These instructions will be used when the Equipment is ActiveAdd an Actor entry setting the Sword Actor as the Actor Class, and the
Equipment.Slot.Weapon.MainHand
as the Slot Tag.Add an Actor entry setting the Shield Actor as the Actor Class, and the
Equipment.Slot.Weapon.OffHand
as the Slot Tag.

Create the Weapon Item Definition
Create a new Item Definition, from the Content Menu, for the Sword and Shield.
Set a Gameplay Tag that identifies this item -
Inventory.Item.Weapon.SwordAndShield
.Add the User Interface Fragment, set the Display Name (" Sword and Shield"), Display Type (Weapon) and an Icon.
Add the Stack Fragment, set the Stack Limit as 1 and Maximum Limit as 1.
Add the Container Fragment, set the Preferred Container Query to indicate the Weapon Container.
Add the Equipment Fragment, set the Equipment Definition defined in the previous step as the Equipment Data.

Create the Backpack container
Create a new Container Definition, from the Content Menu, for the Backpack container.
Set the Display Name as Backpack, and add
Inventory.Container.Backpack
andInventory.Container.Default
Gameplay Tags.Set the Priority to
100
, so this container will have low priority in comparison with other compatible containers.Set the
NinjaInventoryAttributeSet.BackpackSlots
as the Slots Attribute.

Create the Primary Weapon slot
Create a new Container Definition, from the Content Menu, for the Primary Weapon.
Set the Display Name as Primary Weapon, and add
Inventory.Container.Equipment
andInventory.Container.Weapon.Primary
Gameplay Tags.Set
Equipment.State.Activated
as the Default State Tag, defining the initial state of equipment instances added to this slot.Set the Item Compatibility Query so it filters items tagged as Weapons.

Create the Secondary Weapon slot
Create a new Container Definition, from the Content Menu, for the Secondary Weapon.
Repeat the steps above, defining the Secondary Weapon slot, setting
Inventory.Container.Weapon.Secondary
, as the identifying Gameplay Tag.Set the Default State Tag to
Equipment.State.Deactivated
so items are deactivated by default.Set the Priority to
2
to prioritize the Primary Weapon equipment slot.

Configure the Inventory Manager Component
Make sure that Ninja Inventory is added to your project and your Asset Manager was configured, as instructed by the Setup page.
Create a Player State using
NinjaGASPlayerState
as the base class (or a subclass of it). Set it to your Game ModeAdd the Inventory Manager Component to the Player State.
Add the Inventory Provider Interface to the Player State and implement the
GetInventoryManager
function.
Test everything
Press Play and check the sword and shield added to the correct slots and sockets.
Open your Gameplay Debugger, by pressing the pre-defined key. You can access the Gameplay Debugger Configuration in the Project Settings, Gameplay Debugger page.
Expand the Inventory Category and notice that both Containers were added and the Weapon Item is set to the correct slot.
