Free Inventory System - Backend


i am curently developing a Inventory System for a game i am making. I want to share this thing for you, completely free. You can use it in any project you like without asking for permission (maybe a lil note in the credits would be nice but you dont have to).

The whole System (so far) is a Backend for a Graphical User Interface, wich means its just the Code not the fancy Graphics (Yet).

Blueprints & Co:
The zip file needs to be extracted to your Game/Content Folder. Inside the folder you’ll find (in the Contentbrowser) a rInventory Directory wich holds two more Folders (CoreBP, ItemBP), and the main Actor File (Inventory Actor).

The “CoreBP” Folder contains a “Item_Master” Actor and a custom Structure.
The “ItemBP” Folder contains a Sample Item Actor.

Spawning the System / Setup (at Runtime)
Just rightclick in your SpawningBP and chose a “Spawn Actor” Node, then for Class chose the “Inventory_Actor”. The Actor by default is Hidden in Game so dragout a wire from the Transform parameter and use a “make transform”. The Size pin represents the actual Size of your Inventory in Stacks (How big a Stack is depends on the Setup of the Item, ill explain this later).

Useing the Inventory:

(Most of the Time you will use the Core Functions)

Add to Inventory: This is your Bread and Butter Function to Add items to your Inventory.
Target: Reference to the Inventory Actor
Class: The Item you want to add
Amount: How many Items you want to add

Result = False if Inventory is full wich means the amount you want to add cant be added because there simply isnt enugh space

Remove From Inventory: This will remove Items from the Inventory. (the first found in the inventory)
Target: Reference to the Inventory Actor
Class: The Item you want to remove
Amount: How much of the Items you want to remove

Result= False if there aint that much items as you want to remove

Remove From Stack: This will Remove a certain Amount of Items from a Stack (or completely remove it)
Target: Reference to the Inventory Actor
Index: The 0-based(First item is at Pos: 0) Index in the Item Array
Amount: How many you want to remove

Result = Same as above

Reorder Inventory: This functions combines all items/stacks wich can be combined.
Target: Reference to the Inventory Actor

Split Stack: Splits a certain Stack into two
Target: Reference to the Inventory Actor
Index: The 0-based(First item is at Pos: 0) Index in the Item Array
Split At: If you Split a Stack of 15 at 7 the first stack will have 7 Items and the second one will have 8. Must be > 0 and smaller < than the stacks maximum

Result: False if there is not enough space in the inventory to split

Combine Stacks: Combines/Merges two Stacks into one. Or fills the target stack to the maximum.
Item Max Stack: 15
StackA: 5 Items
StackB: 12 Items
= StackA = 15, StackB = 2

Item Max Stack: 15
StackA: 5 Items
StackB: 10 Items
= StackA = 15, StackB = gets removed from the Inventory

Target: Reference to the Inventory Actor
IndexA: The 0-based(First item is at Pos: 0) Index of the Target Stack in the Item Array
IndexB: The 0-based(First item is at Pos: 0) Index of the Source Stack in the Item Array

There are also some Helper functions wich can be called.

Get Item Data from Class: Get the data wich is stored in the Item Actors.
You can modify this one to retrieve other data you specified in the Item_Master actor. (Ill explain this later)

Target: Reference to the Inventory Actor
Class: The Item wich holds the Data you want

(See function nodes and Item_Master BP to understand the returned values)

Get Item Count: Returns you the Amount of all Items of a certain Class in your Inventory.
Target: Reference to the Inventory Actor
Class: The Item of wich you want to grab the Amount.

Result: False if no Item of the class could be found.
Amount: The Amount of the speciefied Item in your Inventory.

Customize & Add Items
If you need any more Item Specific Properties edit the “Item_Master” Blueprint and add the Variables of the desired Datatype to the Blueprint (Graph Tab). You will also have to modify the “Get Item Data from Class” Function inside of the “Inventory_Actor” to be able to return those Values with the function.

As for Adding Items you will create a Blueprint for every Item you want to create. IT IS IMPORTANT THAT YOU CREATE THAT BP OF THE “Item_Master” CLASS!

After you are done with that. Open the created Blueprint and edit its default Values. Those should be self explanary.

Thats it now you have a new Item you can add to your inventory.

The Master_Item BP also has a Event “Use” wich you can override in every single Item to create a custom behaviour for every item. To use the “Use” event you would spawn an item of the desired Item Class (not the Master_Item Actor) and then simple call the “Use” event on that freshly spawned item.

If you have any Questions feel free to ask them, i tried to document the BP-Nodes as good as posible. Ill try to help you as good as i can.
If you find any Bugs please Contact me so i can remove them from the script.

I did my best to design this thing so you dont have to deal with stuff like checking if there is space in the inventory and so on. You just add/remove etc and check if the action was successfull thats all.

And lastly this thing is free as i said, but if you feel genereous you could tip at paypalxD.

Oh… The Download =)

C++ Version!

How to use: An example.

This is how you would spawn the Inventory and access its functions. You can also use the “Inventory Reference” Variable to access the inventory.

The lower BP Stuff shows how you could access the inventory from any other blueprint (Cast the Player Pawn/Controller to the correct actor, asuming that the inventory is spawned & managed by the player character/controller/pawn)

As i wrote above this thing is JUST a BACKEND. There is no Visual representation of the Inventory exept in the Scene Outliner

Hope this helps to get ppl started :slight_smile:

Thank you very much, this is great :slight_smile:

I’m getting a compile error however.
I dropped the “rInventory” folder into my “Content” folder:

Opened the project and tried to compile the IventoryActor blueprint:

Perhaps I’m overlooking something in the instructions?

Thanks again.

aaaaah yes its the NullTransform node :S i did this in a C++ project. just remove the NullTransform node and replace that with a make transform

or create a function lib bp and add a function “NullTransform” wich simply outputs a blank transform

The Download has been updated.

Great, that fixed the issue. Thanks!

Hah, well I hate to keep being the bearer of bad news, but I’m afraid the updated version is worse off then the original.
I downloaded the updated version, just see the difference and…:

This may save you a few minutes if you want to use it to update your version:

This is weird the "Bad cast node " should be a “Cast to Item_Master” node and those 2 open wires should be conntected to it.

I cant reproduce the bad cast node thing. Not in 4.6 not in 4.5 (I did use the Actor from the current file)

Try to cast the Spawned actor to “Item_Master”

this is what it should look like:

Little update to show of whats doable. In this video iam useing the current Inventory System, just added some UMG Voodoo :slight_smile:

That’s an awesome use of widgets, feel like sharing the project to show how you achieved that?

I will include a very basic version of this ui in the free inventory thing. There will also be a pro version on the marketplace wich will include a whole ui for games. (Mostly rpg)
I plan on Making a game menu itself, unit frames, inventory, customizeable hotbars, buff/debuff frames, character screen including equiping of items, quest & dialog system and much more. I try to keep it all blueprint but maybe i need to include some custom c++ stuff for wich se source also be included

Just keep in mind that at the moment, if you want to sell anything on marketplace, it can’t have any C++ code included. So either not go that way, or you would need to wait for Epic to open that up.

Wow, thank you for sharing this it’s awesome!

thank you very much. Please dont hesitate to report any bugs you might occur… Or feature requests

I wasnt talking about precompiled stuff

Well done! I will test it with an easy HTML Front-End using the VaQuoleUI Plugin. Maybe I can post it as an easy example.

Well done! I will test it with an easy HTML Front-End using the VaQuoleUI Plugin. Maybe I can post it as an easy example.

Thats nice iam curently working on a UMG Frontend for this inventory. Iam also changeing some stuff “under the hood” in the next 2 days, to make it easier to work with frontends.

I added a little Tutorial in the Second post because i got asked how to actually use this thing.

little update. Ill upload the latest Inventory Blueprint this evening. Want to prepare a little UMG Integration to showcase how this will work with umg

are you adding the example for umg to the free package today?

have to shedule that to tomorrow… editor decided to crash :S

ouch yeah that always sucks specially if you for get to save everything.

I dont know if its my C++ project iam working in or an editor bug, but working with umg crashes the editor alot. Ive evolved a habit of saving almost every file b4 running my game

nah mine crashes to for some odd reason