2. Consumable Item {{ currentPage ? currentPage.title : "" }}

In this Tutorial i will not explain on how to create Potions or other premade Consumable Items.

Those Tutorials are inside the other Components, where it is needed.

Take a look at them!

In this Tutorial i will explain on how to create custom Consumable Types and how to use them.

If you need special Variables for your Item you can create new ones. Read more in this Tutorial.

1. Create a Gameplay Tag for your Item Type. Call it Item.Type.Consumables.

2. Add you new Gameplay Tag to Item Type Consumable Variable inside the Details Panel of the Inventory Component of your Player BP.

3. Without PlayerTemplate: Add the Interface SP8_BPI_UseConsumable to your Player BP (Class Settings).

4. Create a new Item and set ItemType to Item.Type.Consumables and your custom Consumable Type. I will use Item.ConsumableType.Pet to spawn a Pet.

I will not explain how to spawn the Pet itself, just where you could spawn a Pet inside the Blueprint.

Do not forget to set the other Variables inside your Item!

5. Open your Player BP.

Without PlayerTemplate: Open the Interface Function SP8_UseConsumable.

With PlayerTemplate: Overwrite the Function of the PlayerTemplate SP8_Overwrite_UseCustomConsumable.

Inside this Function do following:

  • Make a switch on the Consumable Type

  • Add to the switch your Consumable Type.

  • Put your logic inside there and now you have 3 Options:

    • You want to remove the Item later, you can just return false. Later you can call TryToRemoveConsumableItem on the Inventory Component.

    • Try to spawn the Pet (in this example) and if it worked return true.

    • Try to spawn the Pet (in this example) and if it failed return false.

Now if you call TryUseItem or TryToUseConsumable on a Consumable Item with your Consumable Type, your logic will be called.

{{{ content }}}