Blueprint Inventory
Contents
Blueprint Inventory
This wiki page will teach you how to make a simple inventory system. I based my initial work off the forum post found here . The core features of this system are:
-
Extendible BaseInventory class
- Inventory weight and max slot size
-
Extendible BaseItem class
- Item weight
- Stackable (optional)
- Structures for inventory slots
BaseItem
Create an Actor Blueprint and give it a name of BaseItem (or something else if you want).
Add a sphere collision component and rename it to PickUpRadius:

Add a static mesh component and rename it to ItemMesh:

Create the following variables:

InventorySlot
Create a Structure Blueprint, name it InventorySlot and add the following two variables:

BaseInventory
Create an Actor Blueprint and give it a name. We will use BaseInventory. Add a StaticMesh component and make it the root component.
Add the following variables:

Macros




Functions

Pick-up Functionality
BaseItem

Your Character
On your character blueprint, add the following variable so that the character has an inventory we can reference.

Then, spawn an instance of BaseInventory (preferably on BeginPlay) and assign it to the variable we created above.

Testing
Place a BaseItem inside your level, and press play. When you walk over the item, you should see a printed message:
