Ninja Bear Studio Plugins Help

Create and Use Consumable Items

This how-to will enhance the Health Potion to add the actual consumable logic.

Part 1: Configuring the Consumable

Create a Curve Table for the Potion

  1. In your Content Browser, create a new Curve Table and set the Interpolation Type to Linear. For this example, we'll name it "TB_Scale_Consumables".

  2. Open your new Curve Table and click the Add button to create a new curve. In this example, we'll name it Potion.Health.

  3. This curve contains Level over Magnitude, add as many values as you find necessary, by clicking the Append Column button.

  4. Once you are done, you should have a similar Curve Table. Feel free to add others, if you like!

    Consumable Level Curve

Create the Gameplay Effect

  1. In your Content Browser, create a new Gameplay Effect Blueprint, using GameplayEffect as the base class. For this example, we'll name it "GE_HealthPotion".

  2. Open your new Gameplay Effect Blueprint and make sure it's Duration Policy is set to Instant. Then, add a new Modifier entry.

  3. Select the Attribute that you want to modify. For this example, we'll use the Health Attribute, from Ninja Combat.

  4. Set the Modifier Operation to Add.

  5. Set the Magnitude Calculation Type to Scalable Float.

  6. Set the Magnitude to 1.0, the Curve Table to TB_Scale_Consumables and the Curve to Potion.Health.

  7. Once you are done, your Gameplay Effect should look like this.

    Healing Gameplay Effect

Configure the Consumable Item

  1. Create or select the Item Definition that will be used for your potion. In this example, we'll use the Consumable_Potion_Health item.

  2. Add the Consumable fragment to the Fragments list.

  3. In the Consumable Fragment, set the Charges to Stack Fragment and the Effect Class to GE_HealthPotion.

  4. Disable the option Use Item Level as Effect Level.

  5. Once you are done, your Health Potion Definition should look like this.

    Health Potion Consumable Fragment

Part 2: Configuring the Gameplay

Configure your Animation Montage

  1. Select the Animation Sequence representing the Activate action. Create an Animation Montage from it and name it M_ConsumePotion.

  2. Open your Animation Montage and add the Consumable Animation Notify State to the frames where the consumable should be displayed.

  3. Set the appropriate Mesh Type for your scenario, the Mesh Asset, the Slot Tag in your character and the Attachment Socket

  4. Add any other Slots to Hide as well, in this case, we'll hide the Main Weapon, represented by the tag Equipment.Slot.MainHand

  5. Once you are done, your Animation Notify State should be similar to this.

    Consumable Notify

Update the Animation Table

  1. Open the TB_Inventory_Animations table, containing your Inventory Animations.

  2. Add another row and set the Montage To Play to M_ConsumePotion.

  3. Set the Montage Query to be compatible any items marked as Potions.

    Store Weapon Montage Query

Create the Consume Equipment Ability

  1. In your Content Browser, navigate to your ability folder and create a new Gameplay Ability using UInventoryAbility_ConsumeItem as the parent. Name it GA_Common_Consume.

  2. Open your new ability and configure the Consumable Query to find any Consumable Items in a Consumable Slot.

    Consume Ability Query
  3. Set TB_Inventory_Animations as the Montage Table.

  4. Add Ability.Consume.

  5. When you are done, your Ability should look like this:

    Consume Ability

Execute the Consume Operation

  1. Open your Character Blueprint or any other location where you are handling Player inputs.

  2. Create a new Consume Operation, using the Inventory Function Library.

  3. Retrieve the Inventory Manager from the character, using the Inventory Function Library

  4. Request the execution of the Consume Fragment Operation to the Inventory Manager.

  5. Compile and save your Blueprint.

Last modified: 12 August 2024