7. Use Potion with Inventory Component {{ currentPage ? currentPage.title : "" }}

We will use a Consumable Item and if this one is used, Health, Mana or Stamina will be regenerated.

Read more about Consumable Items!

1. Create a new Gameplay Tag and call it Item.ConsumableType.Potion.

2. Create a new Consumable Item.

Set the ItemType to Item.Type.Consumables and set the Consumable Type to Item.ConsumableType.Potion.

Also set the PotionStatType to Stats.Secondary.Health (or a other Custom Stat) and the PotionAddingValue to the Number which should be regenerated.

You can setup everything else however you want.

In this Tutorial you can read more on how to create Items.

3. Without PlayerTemplate: Open the Interface Function SP8_UseConsumable and do following:

  • Check if the Consumable Type is the Type Item.ConsumableType.Potion. (You can use a switch as well)

  • If yes, get the Item from the Inventory.

  • Get the Structure out of the Item Data Table. You can use GetItemByItemDT and call UsePotion with the Stat Type and the Amount of the Consumable Option of the Item.

  • If it worked, remove the Item from the Inventory.

4. With PlayerTemplate: Go inside your Player BP to Class Defaults and set the Variable Consumable Type Unlock Crafter Recipe to the Gameplay Tag Item.ConsumableType.CrafterRecipe.

That’s it, now if the Player uses the Consumable Item, he will regenerate some Health (if Health is not at max Value) and the Item will be removed.

You can listen to the PotionUsed Dispatcher to generate some effect.

{{{ content }}}