Ninja Bear Studio Plugins Help

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

  1. Create a Data Table for Inventory Attributes, using the base data from Gameplay Attributes.

  2. Change the initial Backpack Attribute to 20, or any other value that you prefer.

  3. Add the Inventory Attribute Set to the player, via the Ability Definition.

    Inventory Attribute Set

Configure the Equipment Manager Component

  1. Add the Equipment Manager Component to the Player Character.

  2. Implement the Equipment Provider Interface to the Player Character and implement the GetEquipmentManager function.

    Equipment Provider Interface
  3. 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 and Equipment.Slot.Weapon.OffHand. In this example they are mapped to sWeaponMainHand and sWeaponOffHand sockets.

    Actor Socket/Slot Mapping

Replace the Default Weapon Manager

  1. Replace your Weapon Manager Component with the Equipment Adapter Component.

  2. Update the GetWeaponManager function, from the Combat System Interface, so it returns the new version of the Weapon Manager.

    Equipment Weapon Manager

Create Equipment Actors and Definition

  1. Re-parent your base Weapon Class or Blueprint to ANinjaCombatEquipmentWeaponActor.

  2. Add the EquipmentActorInterface to the base class. You do not need to implement any methods from this interface.

  3. 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.

  4. Add a new State Configuration for the Equipment.State.Activated state. These instructions will be used when the Equipment is Active

  5. Add an Actor entry setting the Sword Actor as the Actor Class, and the Equipment.Slot.Weapon.MainHand as the Slot Tag.

  6. Add an Actor entry setting the Shield Actor as the Actor Class, and the Equipment.Slot.Weapon.OffHand as the Slot Tag.

Equipment Definition

Create the Weapon Item Definition

  1. Create a new Item Definition, from the Content Menu, for the Sword and Shield.

  2. Set a Gameplay Tag that identifies this item - Inventory.Item.Weapon.SwordAndShield.

  3. Add the User Interface Fragment, set the Display Name (" Sword and Shield"), Display Type (Weapon) and an Icon.

  4. Add the Stack Fragment, set the Stack Limit as 1 and Maximum Limit as 1.

  5. Add the Container Fragment, set the Preferred Container Query to indicate the Weapon Container.

    Preferred Container Query
  6. Add the Equipment Fragment, set the Equipment Definition defined in the previous step as the Equipment Data.

Item Definition

Create the Backpack container

  1. Create a new Container Definition, from the Content Menu, for the Backpack container.

  2. Set the Display Name as Backpack, and add Inventory.Container.Backpack and Inventory.Container.Default Gameplay Tags.

  3. Set the Priority to 100, so this container will have low priority in comparison with other compatible containers.

  4. Set the NinjaInventoryAttributeSet.BackpackSlots as the Slots Attribute.

Backpack Definition

Create the Primary Weapon slot

  1. Create a new Container Definition, from the Content Menu, for the Primary Weapon.

  2. Set the Display Name as Primary Weapon, and add Inventory.Container.Equipment and Inventory.Container.Weapon.Primary Gameplay Tags.

  3. Set Equipment.State.Activated as the Default State Tag, defining the initial state of equipment instances added to this slot.

  4. Set the Item Compatibility Query so it filters items tagged as Weapons.

    Weapon Slot Query
Primary Weapon Definition

Create the Secondary Weapon slot

  1. Create a new Container Definition, from the Content Menu, for the Secondary Weapon.

  2. Repeat the steps above, defining the Secondary Weapon slot, setting Inventory.Container.Weapon.Secondary, as the identifying Gameplay Tag.

  3. Set the Default State Tag to Equipment.State.Deactivated so items are deactivated by default.

  4. Set the Priority to 2 to prioritize the Primary Weapon equipment slot.

Secondary Weapon Definition

Configure the Inventory Layout

  1. Create a new Inventory Layout, from the Context Menu.

  2. Add all Container Definitions created in the previous step to the list of Container Definitions.

Inventory Layout

Configure the Inventory Manager Component

  1. Make sure that Ninja Inventory is added to your project and your Asset Manager was configured, as instructed by the Setup page.

  2. Create a Player State using NinjaGASPlayerState as the base class (or a subclass of it). Set it to your Game Mode

  3. Add the Inventory Manager Component to the Player State.

  4. Add the Inventory Provider Interface to the Player State and implement the GetInventoryManager function.

    Inventory Provider Interface

Add default items

  1. In the Inventory Manager Component, set the Inventory Layout that was just created.

  2. Add an entry for Default Items and add the Sword and Shield as the Item Data.

Add Default Items

Test everything

  1. Press Play and check the sword and shield added to the correct slots and sockets.

  2. Open your Gameplay Debugger, by pressing the pre-defined key. You can access the Gameplay Debugger Configuration in the Project Settings, Gameplay Debugger page.

  3. Expand the Inventory Category and notice that both Containers were added and the Weapon Item is set to the correct slot.

Test the Setup
Last modified: 29 December 2024