Jump to content
Aveyond Studios Community
Sign in to follow this  
Ant

Tutorial: The Inventory Menu

Recommended Posts

HeroKit comes with an inventory system. The system includes an Inventory Menu, an Inventory Item hero property and the following hero actions:

  • Add Inventory Item
  • Remove Inventory Item
  • Show Inventory Menu
  • Hide Inventory Menu
  • If (Inventory Menu Open)

Note: HeroKit comes with a sample scene that has a fully-functional inventory system. It's called Scene 23 - Inventory Menu Example. You can search for it in the Project tab or you can navigate to it. If navigate to it, open the Project tab and go to HeroKit > HeroKit Samples > Sample Scenes > Scenes > Scene 23 - Inventory Menu Example. 

Create an inventory item

Spoiler

An inventory item is a hero object with a hero property called Inventory Item. The Inventory Item hero property comes with three fields, but you can change these fields very easily. Steps to do this are later in this tutorial. 

HLbVwNvl.png

This is how you create an inventory item:

  1. Create a hero object (HeroKit > Create Hero Object (Asset))
  2. Open the hero object in the Hero Kit Editor.
  3. Click on Properties.
  4. In the Item Type field, choose Inventory Item.
  5. These fields will now populate the Properties window. Enter information for them.
    • Name - The name of the item.
    • Value - The value of the item.
    • Icon - Icon associated with the item.

Add an inventory item to the Inventory Menu

Spoiler

The Inventory Menu is where a player can store stuff that they collect in the game. HeroKit comes with one Inventory Menu. We've kept it simple so that you can customize it or clone it to create your own custom menus.

DXp0UmDl.png

  1. Open the hero object that you want to use and navigate to the event that should add an item to the Inventory Menu.
  2. In the event, add an Add Inventory Item action.
  3. In the Item to add field, choose Value from the list and drag the hero object that represents the inventory item into the field on the right (ex. Potion).
  4. In the If item used, send notification to this hero object field, choose the hero object that contains the event to play when the item is clicked on in the Inventory Menu. (ex. an inventory manager hero object that contains an event called Use Potions)
    • The hero object you choose must be active in the current scene. I advise that you create a hero object that manages all inventory items and that this hero object persists in all scenes (see Use Object in All Scenes action).

Remove an inventory item from the Inventory Menu

Spoiler

You can remove an inventory item from the Inventory Menu with the Remove Inventory Item action. There are two common times when you should use this action:

  • When the player uses the item.
  • When something happens in the game and the item should be removed (maybe you give it to an NPC?).

    vN6hyIil.png

    1. Open the hero object that you want to use and navigate to the event that should remove an item from the Inventory Menu.
    2. In the event, add a Remove Inventory Item action.
    3. In the Item to add field, choose Value from the list and drag the hero object that represents the inventory item into the field on the right (ex. Potion).

      Show the Inventory Menu

      Spoiler

      To show the Inventory Menu, use the Show Inventory Menu action. I would add this action to an event on a hero object that is watching for user input (ex. right-mouse click).

      1z4FVXb.png

       

      Hide the Inventory Menu

      Spoiler

      To hide the Inventory Menu, use the Hide Inventory Menu action. I would add this action to an event on a hero object that is watching for user input (ex. right-mouse click).

      irZK4CR.png

      Toggle the Inventory Menu

      Spoiler

      If you want to use the same user input to open and close an Inventory Menu, you can do this. There are a couple of options here, but an easy one is to use the If (Inventory Menu Open) action. 

      plKmCgv.png

      Add, remove, or change fields for inventory items

      Spoiler

      The default inventory item has three fields: Name, Value, and Icon. You don't have to be stuck with these fields forever. You can change them. To change the fields for an inventory item, open the Inventory Item hero property in the Hero Kit Editor. This file is located here: 

      fFZ2TCj.png

      ADCvjpL.png

      Notes:

      • If you need help editing this hero property, check out this topic.
      • After you edit the hero property, you need refresh your hero objects (specifically, any hero objects that are used as inventory items). To do this, open any hero object in the Hero Kit Editor, click the menu icon (right of hero object's name at top), and tap the Refresh Hero Objects button.

      Warnings:

      • If you remove fields or rename fields, you'll need to update the Inventory Menu itself. Specifically, you'll need to modify Inventory Slot (prefab) and Inventory Slot Controller (hero object). 
      • If you want to make drastic changes to inventory items, I advise you duplicate the menu prefabs, hero property, and hero actions associated with the default inventory system.

       

       

      Share this post


      Link to post
      Share on other sites
      Sign in to follow this  

      ×