Skip to content

Simple Inventory System



Create a folder called Inventory
Create a BP component actor, name as BPC_Inventory
image.png
Add inventory array String variable
image.png

Add new function to implement the ability to add things into inventory:
name function as Add item to Inventory
create graph as follow (drag ADD to centre of function node, to make new item output):
image.png

Go to 3rd person BP:
Search and add BPC Inventory Component
image.png

Create a BP actor called BP_Inventory Item (set in pickup tutorial, add a cube as mesh, collision box, and variable)
create variable called item, set as string and make it public
image.png

Create a BP interface, name as BPI_InventoryItems
Name the function as Pick Up Item,
add Outputs, change to string and name as item
image.png

Go to BP_Inventory,
Class Setting, choose the interface
image.png
double click the pick up item interface on BP inventory graph
image.png
image.png

Go to 3rd person graph, add pickup nodes by E hotkey

image.png

Now the item can be picked up (showed on print string) in scene

To destroy actor after pickup:


Back to BP_inventory
Event graph:
image.png
Pickup item function:
image.png

Create Inventory Widget:


Name as WB_Inventory
image.png
To 3rd person BP
(promote variable inventory widget)
image.png
Now click tab will show the widget in scene
Continue after add to viewport (show mouse cursor)
image.png

Create a new widget, called WB_ItemSlot
Just add a canvas and text, name as Item Name, change to Desired on screen size
image.png
image.png

Back to WB Inventory,
Rename the Vertical box, and make it is variable
image.png
image.png

go to event graph
image.png

Go to BPC inventory, function (add item to inventory)
image.png

Now the inventory only shows picked item when it’s already opened (tab). Coz everytime a inventory list is opened, old one is removed and a new one is created.
To make picked items showed anytime once pressing tab
Revise the 3rd person BP graph:
image.png
Also on press E (pickup) graph:
image.png


Add item names on inventory list:


In WB Inventory event graph, add input variables on custom event node:
image.png
Go to WB ItemSlot, rename as ItemName and be variable
image.png
Back to Inventory event graph
image.png
In BPC inventory, connect new item below:
image.png
Name the inventoryitem drag in scene, e.g. wood (make BP inventory Variable item be visible first)
image.png
Now when picked up, the inveotry show the item name:
image.png

Now the old inventory items will be replaced by newly picked item, to solve it:
In 3rd person BP:
Delete Set inventory widget node between set visibility and set input mode game only node
image.png
Also, connect the follow is valid node to for each loop:
image.png

Modify Inventory list:


In WB Inventory
Add background blur with follow setting:
image.png
and image (black with 0.3 alpha)
image.png

Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.