[Tutorial] Basic Inventory System in Blueprint

Introduction

This is part two of a tutorial series, please first complete one of the following tutorials:

In this part I will show you how to build a basic inventory system to pickup, select and drop items from a player’s inventory. Please note that this tutorial was written based on the C++ Part 1 tutorial, some names or nodes may be slightly different if you work from the Part 1 Blueprint tutorial, but the concepts remain exactly the same.

Building an inventory system is not beginner level. It is expected that you have a basic working knowledge of Blueprint and Unreal Editor. To keep the tutorial of a reasonable size I will not go in-depth for every node, you may of course ask any questions in the comment section!

DownloadTutorial2_Content (Includes post-process for item highlighting)

Project source is available on GitHub!

Built for 4.0. Last updated: 4.7

The Concept

Building on the UsableActor C++ class from part one we respond to On Used events (“E”-key in tutorial) by spawning a blueprint instance in the character’s inventory and removing the object from the world. When dropping an item (“F”-key in tutorial) we spawn the actor back into the world. I’ve split the inventory and in-world objects into two separate blueprints, this requires a ‘mapping’ between the who which may be undesirable for very large projects, I intend to tackle this issue when moving to a more advanced inventory system (using DataTables) in future parts.

ue4_inventorybasics_example

Preparation

First we create the blueprint classes so we can more easily move through the implementation in a single pass.

Create a new Blueprint based on UsableActor and name it “BP_PickupActor“. This actor is visible in the world and responds to On Used events.

Now create another Blueprint based on Actor and name it “BP_InventoryActor“. This actor holds inventory data such as display name and could hold additional information like item weight and a thumbnail.

Input Mapping

Add the following input mappings to your project. The mapped actions are available in Blueprint (We will implement these in the Character blueprint)

ue4_tut2_inputsettings

BP_PickupActor

This blueprint exists in the world and can be picked up by the player.

Create a new variable “InventoryClass” of type class’Actor’. This variable holds the class that is created when this item is picked up by a player. After creating the variable, compile and assign BP_InventoryActor as the default value.

pickupactor_01

On Used event handles the response when a player presses “E”-key while hovering over an item. Do note that “Add Item” is a function of our inventory character that we did not create yet. We’ll get back to that later in the tutorial. My character class is named BP_BasicInventoryCharacter in the image below, replace this cast with whatever your Character class is named after (the one that will hold your inventory items)

Tip: If you’re having trouble with “Cast To” nodes, always drag a line from the pin/variable you want to cast.

pickupactor_04

Begin Focus & End Focus events toggle the “Render Custom depth” on our Static Mesh. If enabled the mesh is drawn into a special depth rendertarget that is used by our custom post process to draw the item outline. For more info on the used on Custom Depth, click here.

pickupactor_03pickupactor_02

Next we assign the defaults for this Actor. Enabling “Simulate Physics” is optional and depends on your game. If you don’t enable physics you may need to adjust your Drop Function later in the tutorial to trace to the floor to find an appropriate drop location instead of letting it fall on the floor.

ue4_tut2_pickup_defaults

BP_InventoryActor

This blueprint holds item specific information such as display name for the HUD and the class to spawn when dropped.

Variables

  • DisplayName (type: text)
  • PickupClass (type: class’Actor’)

Now compile this blueprint and assign the BP_PickupActor as default value for our PickupClass-variable and set a name for DisplayName or it will not show up in your HUD later in this tutorial.

ue4_tut2_inventoryclass

Compile once more, we’re now done with this Blueprint.

Character

The character owns the inventory array and handles pickup/drop logic.

Add the following variables:

  • InventoryItems (type: BP_InventoryActor) as Array, click on the grid-icon next to the type.
  • SelectedItem (type: int)

ue4_tut2_character_variables

You can set the category to “Inventory” to keep it tidy.

Character Function: SetSelectedItemIndex

Create a new function with an integer as input and name the input “New Index” (see image) This function clamps the selected item index between 0 and the total number of items you have in your inventory. It will be called after dropping an item from your inventory into the world.

inventory_func_setselecteditemindex

Character Function: AddItem

Create a new function called “AddItem“. Now step into this function and select the “Add Item”-node, we must add a new Input “InventoryClass” of type class’Actor’. Remember that our Blueprint BP_PickupActor called this function? Don’t forget to update that function now that the function is available.

ue4_tut2_additem_input

Now to ahead and implement the logic of this function as seen below.

We spawn a new inventory actor and add it to the player’s inventory. The Make Transform node is left as default since the inventory item is not visible in the world itself (We could opt for a more base class like Object or a struct that do not hold location variables, for simplicity I chose to use Actor instead)

ue4_tut2_additem

Tip: To cast the Return value of “SpawnActor” you must drag a line from the ‘Return Value’ and make sure “Context Sensitive” is enabled. Otherwise the “Cast to X” nodes will not show up!

Character Function: DropItem

Create a new function “DropItem“. This function gets the selected item index and spawns a Actor in world in front of the player (if any object is held in the inventory) after the Actor is spawned we remove the item from the inventory.

dropitem_01

EventGraph (Root)

In the EventGraph of Character we implement the DropSelectedItem event (We previously mapped this in the Input settings) we simply call the DropItem function and update the selected item index so it’s valid in case we removed the last item of the inventory array.

The remaining two events implement the mouse scroll to move up and down the inventory. The index is clamped so it cannot go out of range of the total number of held items.

ue4_tut2_character_eventgraph_combined

BP_HUD

The HUD draws the items we currently hold in our inventory and the selected item is drawn slightly larger.

Variables

Add two new variables of type float InventorySpacingY and InventoryLocationY. Compile the blueprint and assign the following defaults:

ue4_tut2_hud_variables

EventGraph

ue4_tut2_hud_02

The above blueprint will look like this, where the selected item is drawn slightly larger.

ue4_tut2_hud_ingame

BP_GameMode

Create a new game mode or update your existing GameMode blueprint. Make sure it’s using BP_HUD.

ue4_tut2_gamemode01

Go to Window > World Settings and verify the correct gamemode is set for your level.

Post-Process for Item Highlighting

Select your primary post-process of your level (the default maps use a global post-process volume “Global PostProcess”) or create a new volume.

Make sure Unbound is checked so it affects the player regardless of position and assign the provided PP_OutlineCustomDepth material in the Blendables array.

ue4_tut2_postprocess01

We’re done!

Now you can try out your inventory system.

ue4_inventorybasics_example

Creating Additional Items

If you want to create additional items such as a weapon you have to create child blueprints for both BP_InventoryItem & BP_PickupItem. Update the default values for both objects to your new blueprints and assign a new model.

A more advanced system could use DataTables as mentioned at the start of this tutorial.

Troubleshooting
  • Make sure you’ve assigned all default values (DisplayName and InventoryClass / PickupClass variables)
  • Check your Input mapping if all keys are assigned (“E”, “F” and scroll up/down)
  • Check if correct game mode is used and has your HUD class assigned.
  • If your objects are falling through the floor, make sure they have a collision primitive assigned.
How to use “Cast To”-nodes

ue4_castto_procedure_07

Project source is available on GitHub!

221 Comments

    • Make sure you do not call DestroyActor() on the “begin focus” event but only after triggered the OnUsed.

  1. Going to give this a follow, now that you have a BP based Usable Item layout. Thanks again for putting that out for people like me that don’t do so well with the C++ end of things.

  2. Ran into another node snag… From the GET attached to Inventory Items Array, you have it plugged in to the Class pin on the SpawnActor using some node that I cannot get to appear (Target left, Pickup Class right). What exactly is this node and where do I create/find it?

  3. Nevermind my question about the pickup class node, I had accidentally skipped ahead when I set up the BP_InventoryActor and forgotten to set the two required variables.

  4. I hit another small wall. I can’t seem to get the event onUsed. I created the new BP off of UsableActor so it has the three functions created in tut1. I’m able to get the onUsed function but not the event onUsed. I must have missed something once more.

    • Hi,

      Double check your parent class is of “BP_UsableActor” (if you used the blueprint example) or “UsableActor” (from the C++ example) by pressing “Blueprint Props” in the top window of your blueprint (make sure “Graph”-tab is active of Defaults-Components-Graph) The next thing to check is “Context Sensitive” in the right-click menu when attempting to create the node, it must exist under the “Add Event” category. Hope this helps.

  5. Thanks tomlooman, turns out I was inside the event graph for the BP_UsableActor. Silly mistakes. Thank you for your help.

  6. Now I can’t seem to get the AddItem node to appear like you did in the image under the BP_PickUpActor Section. Did I miss the creation of an AddItem function?

  7. Drag a line from “As My Character C” pin in the node left of the AddItem, otherwise it will not show up in the available nodes. Also make sure Context Sensitive is enabled again. This is one of those implicit tricks of Blueprint 🙂

  8. Thanks for this tutorial, it’s just perfect ! 🙂

    Everything works fine for me, except when i drop my item, i can’t see it. (The item is removed of the inventory, but visually, he just disapear, i can’t even see it fell on the floor …)

    Any idea of what i did wrong ?

    • Double check the transform you use to spawn the item into the world. You can check if the item was spawned by checking the Scene Outliner (eject your character using F10) you can check its location with the outliner as well.

  9. Oh, I’m stupid, i could have think to check in the outliner …
    Anyway, when i pick my item named BP_pickupActor, it becomes an BP_InventoryActor.
    When i drop it on the floor, come again one other BP_InventoryActor.
    So pick and drop create 2 instance of BP_InventoryActor, but it’s not a BP_pickupActor anymore.

    I’m quite lost 😀

    Thanks for the help 🙂 (and sorry for my english)

    • Double check the variable of bp_InventoryItem named PickupClass and make sure you assigned the correct value eg. Bp_pickupitem. I hope that helps 🙂

  10. It works ! <3
    That was my bad, my Pickupclass default value was inventoryActor instead of pickupActor, i thought that was correct.
    Thanks a lot for answer so rapidly, for this tutorial and for everything ! 😀

  11. Sorry to ask something more but it looks strange.
    When i pick my item, it remove the pickupActor and create an InventoryActor. But when i drop it, the inventoryActor isn’t removed, so i get 1 pickupActor and 1 InventoryActor for one object.
    And many more variable inventoryActor for each item picked….

    • Hi Laury,

      Make sure you call “Remove Index” after you spawn your object back into the world. You can see these nodes under header: “Character Function: DropItem” in the tutorial. Hope that helps! 🙂

        • I realize my mistake. Destroy must be called on the inventory item after removing it from the array of items. This was pointed out by a community member earlier, I will update the tutorial. So all you need is that extra node and it should work.

  12. “I realize my mistake. Destroy must be called on the inventory item after removing it from the array of items. This was pointed out by a community member earlier, I will update the tutorial. So all you need is that extra node and it should work.”

    Do you mean a “Destroy Actor” node? If so, what do you hook up to target to make it work?

  13. Just implemented your update and it works perfectly. Thanks again for the whole tutorial! You might want to put together a quick tutorial for making additional items for inventory though. You said:

    “Creating Additional Items
    If you want to create additional items such as a weapon you have to create child blueprints for both BP_InventoryItem & BP_PickupItem. Update the default values for both objects to your new blueprints and assign a new model.”

    … but you may want to go into depth on it just a little bit. Which variables/values need to change? How can we add “sub-class” items that work differently or are called by different blocks (i.e. Weapons, food, potions, valuable, etc). Obviously they are all based on “PickupClass” and “InventoryClass”, but it would be nice to see how the MASTER would expand this system.

    Also, any chance you could show how you plan to interface this with a proper HUD for inventory? Slate is CRAZY advanced, and UMG won’t be out for months. Would be nice to have a drag-n-drop inventory with the ability to drop/activate/equip from a UI, using this exact system. Any plans on working on that kind of stuff?

  14. Thanks for feedback Gabriel! I will add some additional information so its clearer for everyone how to expand the system.

    I don’t have a current UI plan. I’m mostly sticking with simple HUD elements and debug text until Unreal adds UMG (Which like you said might take a while) OR if I move beyond the prototypes and into production.

  15. Hi mate, very useful tutorial, but I don’t know what I’m doing wrong, in the BP “BP_PickupActor” I haven’t the events OnUsed, Star Focus Item and End Focus Item, I’ve created this BP based on “BP_UsableActor” (child) as well, what is going on?

  16. Never mind I was confused, i get them at then end. Last thing, have you edited the original events from Part 1 of tutorial? Before was named “Begin Focus & End Focus” and both with Actor parameter like input, now “Start Focus Item & End Focus Item” and without the Actor parameter.

    • Hi, you are right. I made two versions of the UsableActor tutorial (one in C++ and the other in Blueprint) I accidentally used slightly different formats for both.

  17. Thanks for the clarification, you know if the are any incoherent between the vs. you made this tutorial and the nowadays one? I finish all and don’t get the result. There no response in the “raycast” over the object and of course the highlight, when I created the base UsableActor BP, I place a cube mesh and move to scenary to check if visible, then create the PickUpActor based on this and don’t replace the mesh like you comment (“By deriving from StaticMeshActor any child blueprint can easily overwrite the mesh property once you start implementing multiple item types”) and for Collision I tried different one in both

  18. Hi Tom!

    This was a fantastic tutorial – it works great. However, I’ve run into a slight snag when it comes to dropping my item. I can drop it just fine, but it spawns far, far below me, close to my KillZ height.

    I’ve fiddled with the transform, but it doesn’t seem to do anything. I am outside of the world bounds, but I’ve disabled the bounds check. Could that have something to do with it?

    • Hi, thanks! I don’t know how the World Bounds affect your transform. It may very well limit a transform to only exist within the world bounds, hence why it wouldn’t appear where you expect. Can you get the same code in a new level, which should spawn you at 0,0,0 ?

      • I gave it a whirl, and sure enough it spawns where it’s supposed to be. I moved the other map so that it’s within the world border again, but it still doesn’t work on that map. I’m probably doing something wrong 😛

        There’s another thing, too – if I wanted to change the scale of the spawned actor when I drop it, I’d do that in the “Make Transform”, right? I tried changing it there, but it didn’t do anything.

        • I’d say that depends on the design. If your object is simply not the correct scale, I’d fix it in the model or actor blueprint instead. (You can use “Build Scale” in the Static Mesh Editor) or you could change the scale of the in-world actor blueprint.

          But on the other hand, setting the scale in the MakeTransform *should* work. This may be a tricky error because the component in your pickup Blueprint is using “Worldspace”-scale instead of relative scale. This can be toggled at the position/rotation/scale properties of your blueprint (make sure you double check this for both the blueprint and the sub-component which holds your mesh!) I would think your sub-component should use Relative-scale so that any parent that gets scaled up will distribute the change to it’s children (eg. the mesh in your case)

          I hope that made sense!

  19. In the part 1 to create the BP_UsableActor says…
    “First create a new Blueprint that will act as our item to be destroyed, derive it from StaticMeshActor… By deriving from StaticMeshActor any child blueprint can easily overwrite the mesh property once you start implementing multiple item types”

    When I create a new Item BP based on BP_UsableActor, the mesh of the BP_UsableActor don’t be replaced by the new one, can anybody explain better the properly way to do it?

    • If you have derived BP_UsableActor from StaticMeshActor you should be able to overwrite the mesh property on any blueprint that derives it.

      • Maybe I don’t understand so good english… I Create Actor BP , then I add on it a static mesh ( basic cube for example). Create a new BP based on previous, in the new one I can add another mesh or whatever but not touch the root one

        • Hi Juan,

          When you create a new Blueprint based on the previous one – you should replace the static mesh in the “Defaults” tab of your new blueprint so it will only use 1 mesh at any time. Also make sure that the mesh has a collision set or the raytrace may not return a hit result for your new meshes.

          • Thank you for response, my faul was I created the base like normal Actor instead a StaticMesh one. Last thing I can’t comprehend… any BP_PickupObject needs itself BP_InventoryItem, so for each pickup object must have both personal BPs?

          • Yes, that is to keep inventory and in-world objects separate. You may choose to use a single BP for both inventory & pickup, you will need to handle the creation & destruction of the mesh differently in that case.

            In a future update I will use data tables (.csv / Excel) which should reduce the number of BPs to only two instead of two for each item you have.

          • Thank you tonight I’ll try when I be at home. Sounds perfect what you suggest, in database or files to store the relative data. I expecting like number 1 fun xD

  20. Hey, there are some issues with the download content. I cant drag it into nor use the ingame import. My UE4 says he doesnt know .uasset and there is a failure.

    • I had that too – UE4 can’t import uassets directly. Just drop it into the folder you want inside your project and reload it – it’s worked out great for me so far.

      • I find the “Migrate Assets…” works well from the source project and keeps links in-tact. Right-click an asset to copy from the downloaded project and in the dialog select the destination project’s Content folder.

  21. Got another question you wrote this: Now create another Blueprint based on Actor and name it “BP_InventoryActor“.
    Do you mean the UsableActor BP ? I did it that way. Or shall i create a new BP with the Name Actor and than another one based on it ?

    Sincerely

    • No, you should create a new Blueprint based on Actor (the built-in class) and name it BP_InventoryActor. The UsableActor class is not relevant in that part. Also, you don’t need to create a BP named “Actor” since it already exists in the engine itself.

      Hope that helps.

  22. Awesome Tutorial, I’m having a little trouble at the “Character Function: DropItem” part: I’ve got my InventoryItems Variable set up and am getting it in the Drop Item function, but I can’t figure out how to get that node that you are using between the “Get” and the “SpawnActor” nodes. It’s the node that says “Target” on the left and references the “PickupClass” variable from the BP_InventoryActor on the other end.

    I’m not sure how to get that node into the blueprint. I’m sure I’m overlooking something very obvious, but I’ve check to make sure I have that variable set up in the correct BP and all the other things I can think of.

    • Hi Trevor,

      I’ll try to give a few pointers that might help you out.

      InventoryItems array variable must be of your type BP_InventoryItem and not Actor or similar. Next it’s important to have “Context Sensitive enabled” when dragging the wire from Get. And make sure the other blueprint is compiled after any changes.

      I hope that helps, otherwise we’ll keep digging. 🙂

    • Hi, if you have declared InventoryItems var like BP_InventoryActor and in this BP you have declared the Pickup class, must appears when you drag from GET

  23. Hey,

    thanks for a great tutorial. I’m running into a small problem though.

    When running this on multiplayer everything works great for the server. The client’s inventory though doesn’t get updated. When the client uses an item it gets destroyed as it should be, but doens’t get put in it’s inventory.

    I have BP_UsableActor set as replicated and ServerOnUsed as run on server+reliable.

    Any ideas?

    • Hi,

      By default the inventory tutorial doesn’t fully support multiplayer. The array of items for the client need to be replicated. I’ve seen this doc page on the topic: https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/Components/index.html (Specifically header: “Use Cases” near the bottom) Hopefully that gives you a few pointers on how to handle this. I haven’t actually done any multiplayer support for inventory system yet, perhaps something for the future.

    • Thanks for the reply, I tried to add some changes and I found how to make it work in multiplayer. Might not be pretty but maybe someone will find it useful.

      However how secure it is against cheating I don’t know, since you’ll see I disabled run on server from the ServerOnUse custom event, and had it run on client (reliable). So basically the client is responsible or adding an item to its own inventory.

      These are the changes (note BP_Character from the tutorials is called Mycharacter in the images below):

      BP_UsableActor – in defaults replicate as the tutorial says

      BP_PickupActor – in defaults replicate, always relevant, replicate movement

      BP_Character: custom event ServerOnUsed – not run on server but run on client…

      BP_Character: Create two custom events, one to destroy (ServerDestroy), one to drop (ServerDrop), both run on server and reliable: http://i.imgur.com/fYF5Eaw.jpg

      BP_Character function DropItem, replace spawn actor by calling the custom event ServerDrop: http://i.imgur.com/g7rjR7T.jpg

      In the BP_Character create a new function called DestroyItem with an actor input, then call the custom event ServerDestroy : http://i.imgur.com/MyEI1D5.jpg

      in the BP_PickupActor, at Event On Used replace destroy actor by a new cast to BP_Character, function DestroyItem with a self reference as the actor parameter: http://i.imgur.com/GAXwFPL.jpg

      As far as I can find these are all the changes I made and I got inventory and items updating on both client and server.

      Haven’t found a way for the server to update the inventory of the client, but it’ll do for now!

      • Hi thanks for this info. If you decide to build a complete multiplayer game then a server should be the authority in deciding what is added/removed. Clients only get a copy of this data. I will have to deal with multiplayer code a lot more soon enough, I’ll likely publish a few tutorials on how that’s done.

        But I think you shouldn’t worry too much about security while you’re still learning UE4 / Replication (it can get very complex, very quickly) It’s good to keep this in mind for the future though.

  24. Hello I like the tut and I know that I am showing up late here. I am having a problem tho. When I place BP_UsableActor in the map it highlights but doesnt let me pick it up and the BP_PickupActor lets me pick it up but it wont highlight. The PickupActor has the parent UsableActor.

    • That you cannot pick up the BP_UsableActor would make sense since that piece of logic is defined in PickupActor. I’m assuming you only used the Blueprint part 1 tutorial so you only have BP_UsableActor available and not the C++ counterpart. Make sure you don’t overwrite the the events in your pickupActor, I will double check to see if nothing broke in Blueprint since I last used it.

  25. Hello, I am a university student from Romania, and I just love your tutorials, but I have question.
    Can you make a tutorial on how to pick up objects from the scene and place them elsewhere? Like picking up the companion cube in Portal, and placing it on buttons. How to achieve that “hovering” effect in front of the player?
    This is the last thing I would need for my game, and I haven’t found any tutorials for this yet.
    Thanks in advance! Have a great day!

    • Hi Seth,

      First of, thanks! Glad you like the tutorials.

      What you are looking for is Attach To Parent node in Blueprint. You can use this to attach it to the character (you have this variable available in the OnUsed event) and instead of calling Destroy you can Attach Actor To Parent with character as the parent. You may need to tweak the offset setting of that node, I recommend starting with KeepRelativeOffset.

      In your character class you will need an extra boolean that keeps track of whether you are holding your cube. If this bool is true then you drop the item (call Detatch From Parent) if it was false you call the regular code from the tutorial that handles OnUsed events etc.

      I hope that gets you started. Feel free to ask questions if you get stuck along the way.

  26. Hey tom, I Have the book pickup. everything works perfectly. But how do i add other items? i wanna be able to add another item into my inventory and USE it. I Have a hunger system, everytime i click on the apple it destroys the actor and adds points to my hunger system (The more points, the less hungry you are) How would i add the apple into my inventory, and press a certain button to eat it, and than it gets removed from my inventory and it adds points to my hunger system? please help me. i wanna be able to add items with logic into my inventory and actually USE them.

  27. Also, i have “UsableActor” and “PickUp actor” why do i need both? lol amazing tutorials btw i just love them.

    • UsableActor is for just about anything interactive in the world (could be a door and/or lever for example) the pickupactor has specific implementation for the inventory system.

      • Oh okay, that helps alot. I was confused lol So how would i add another item into my inventory? I have the book but i wanna add more items to pickup and put into my inventory. How would i do that?

        • Hi Nicky,

          There are many ways to go about this. One is to create a child Blueprint with a new mesh (the simplest way and quick ‘n easy when prototyping) A better approach is to use DataTables that allow you to define a great number of items in a single Excel sheet. I’ve done some basic work with DataTables in 4.3, not sure if I’ll get the time to write a tutorial on this soon though.

          On a brighter note, in response to your earlier question on using an Apple to reduce hunger – I just started on building a source package containing the tutorial and custom apple class that reduces player hunger when eaten in the inventory. Hopefully I get some time coming week to finish this up proper.

          • Thank you for your reply, tom. I know u have to create a child blueprint, but HOW would i go about doing this?

            I create two new blueprints: One under the “BP_PickupActor” class, and one for “BP_IventoryActor” class. But after i make them, HOW would i set them up properly so it can be its own individual item like the book? Cause after i make the two new blueprints i’m completely lost. I wanna pick up my second item and i want it to work exactly like the “Book” item i created. How would i set it up to work properly?

          • And also thank u for making that package! I cant wait to use it. When can we expect a an inventory tutorial with DataTables? Sounds very interesting.

          • I’d like to explore DataTables some more, my current game project does not require this feature though so I can’t make any promises.

          • Okay, Well until that package comes out is there any way u can tell me the process of adding another item into my inventory? I cant figure it out. I would really appreciate it lol

          • You need to update the Default values (in the Defaults-tab of your newly created blueprints) and update the InventoryClass and PickupClasses variables to point to the new blueprints accordingly (they point at each other so they can be picked up and dropped like the base classes)

            It’s important to create an output variable for the OnUsed function, this is NOT part of the tutorial, but I found that Unreal does not properly recognize this as a function without at least one output! This is something they will fix in a future update. For now it should like the following example:
            https://twitter.com/t_looman/status/496081949052928000 (it’s not the exact same function, but it’s the same idea of having one output) This way in your child Blueprint you can override the function as it will now show up in the variables/functions menu of the EventGraph-tab.

            With the updated variables you could add a function to your InventoryItem like the image above, adding “Use” and binding this to input of your character so that the selected item will call Use when pressing….”G” for example. I’m setting up a basic example for this using your previously mentioned feature of eating an apple (Unfortunately I lost the apple mesh from the old Morph Targets sample of Unreal)

            I hope this gets you started, if you need any help let me know.

          • Thank u! I will try it out in a little bit haha.

            I downloaded The new 4.4 update, and i been messing around with UMG and its pretty amazing.
            Can u PLEASE do a tutorial on how to implement this inventory system with UMG? That’ll be AMAZING. I’ve tried to do it myself but when it comes to UMG im still very lost as im not that familiar with it lol but that’ll be crazy if u can implement this to umg. I also seen your comment on the umg documentation lol

          • I worked with UMG a bit, but it crashed on me a few times. I’m waiting for at least one more update (the final 4.4 or 4.4.1 update) before I’ll work with UMG again.

            Making an inventory with UMG sounds like fun, first I’ll bring my shooter HUD to UMG, but who knows 🙂

          • Yeah its been crashing on me too, i had to delete the blueprint and start all over again and it seems to work fine. Just dont add anything weird to the designer graph, just add the common ones. I added the viewport widget just to see what it does and it crashed on me. But an inventory with umg sounds awesome. I Wanna get my hunger system running on umg too. My hunger system is just a variable that starts from 100 and drops every 10 seconds by 1. How can i add a percentage text from 100% to 0% based on my hunger variable in umg?

          • I’d recommend doing it by binding the textfield to a function (so use “Create Binding” instead of choosing your hunger variable directly) and building your string format in that. So you take your hunger integer and build a format that appends %-symbol and returns it as the text variable of the function.

  28. Hi Tom!

    Spurred on by your suggestion, I’ve started working on a DataTable-driven inventory system – it’s going well so far! I can create an arbitrary number of items using one BP each. I can pick up items and view them in an inventory and play sounds when picking up or dropping them.

    However, when it comes to dropping the item I’ve hit a bit of a snag. I’ve got a TAssetPtr PickupClass; to the BP associated with the item in my DataTable struct, but I can’t get this to spawn back into the world. If I directly reference the item from inside my character (by setting it manually at a Cast to Actor node) it spawns just fine, but I can’t seem to figure out how to get the generated class from a direct UBlueprint reference. I’ve scoured answerhub, but I can’t find an answer.

    Do you know how to take a direct pointer to a blueprint and use that to spawn an actor of that blueprint into the world?

    Thanks a lot for the inspiration so far 🙂

    • Hi! Great to see you’re working with DataTables! I have not used TAssetPtr’s specifically in that way, so I’m not sure what is going wrong for you. Perhaps I will discover this issue myself in the future and I’ll let you know.

      • I got it working!

        Blueprint wasn’t working with me, so I moved the entire thing over to C++ and it’s working like a charm. I love datatables! :3

        Not only that, but it’s working brilliantly in multiplayer as well. Thank you once more for getting me going ^.=.^

  29. Hi Tom,

    Thanks for your tutorial – exactly what I was searching for. I finished both parts (blueprint, not C++) and just added a second item. I understand that duplicating the two blueprints and changing the blueprint references and the mesh is not the best way to add especially a lot of items. However, I would like to add 4 or 5 items for prototyping purpose, but it seem like the AddItem function in MyCharacter prevent me from creating more items. The problem I see here is we casting to the specific InventoryItem, and thus it can just work for one item. Please correct me if I’m wrong or missing something here. Any ideas on how to quickly bypass this?

    • All the items should derive from InventoryItem Blueprint so the casting won’t be an issue. I have seen an issue where the functions of the base blueprints cannot be overwritten because Unreal recognizes them as Events and not Functions. To workaround this the functions you need require an Output (eg. like we defined Character as an input for the functions)

      The InventoryActor from the tutorial doesn’t yet have functions so you should be OK (this issue does apply to the PickupActors though!)

    • Hi Tom, thank again. You are completely right – the cast failed for another reason – everything works like a charm now 😉 Thanks again for your time – have a great day!

  30. Hi Tom,
    The tutorial has been great. I’ve hit a bit of a wall however early on. i can’t seem to cast anything from the event on used in the ‘Pickup Item & Destroy’ portion. I’ve gone through the set up in the BP_UsableActor tutorial and I can’t seem to figure out what I’m missing.

    • Hi Anthony! If I’m understanding your issue correctly, you are missing the correct “Cast To” nodes? In that case make sure you have both Context Sensitive enabled and drag a line from the “Character”-input pin of OnUsed.

      I hope that helps!

  31. Hi Tom,

    I’ve just tried both parts of the Blueprint tutorial and have a problem with my BP_PickupActor instance in my scene not getting picked up. Highlighting works if I give BP_UsableActor a mesh and place it in my scene, though BP_UsableActor instances obviously don’t get added to MyCharacter’s inventory (since there is no such logic in BP_UsableActor, such code is only found in BP_PickupActor). Am I doing something wrong that is preventing BP_PickupActor from being highlighted? I’ve already confirmed that BP_PickupActor is a subclass of BP_UsableActor by checking the Blueprint Props button. This bug is quite confusing because without carrying out a successful hit trace to BP_PickupActor (a successful hit trace should highlight it), I obviously can’t pick it up and add it to MyCharacter’s inventory.

    • Hi! I’m not sure sure what could be going wrong for you there. Perhaps the functions are overriden in the PickupActor? I’ve uploaded the project source here: https://github.com/tomlooman/ue4-tutorials you can download a zip if you don’t have git.

      Are you using the same mesh on both classes? If not, please check if the mesh used in PickupActor has atleast one collision primitive.

      If none of that helps, let me know and we can dig further.

    • I tested stuff, then posted a comment after checking that stuff. Then I went through this tutorial again, deleting both BP_PickupActor and BP_InventoryActor (BP_UsableActor from the previous tutorial gets highlighted just fine and behaves as expected). It turns out that I forgot to set my InventoryItems array to the variable type BP_InventoryItem. Such a bug probably has nothing to do with the highlighting issue, but in any event, I did want to mention that omission that I made while going back over the tutorial. FTR, fixing the variable type of InventoryItems in MyCharacter did not fix the problem of not being able to highlight, pick up, or add instances of BP_PickupActor to my inventory.

      To reiterate my earlier comment for reference, even though it’s already here, I’m only reposting it to follow-up one the InventoryItems array class:

      Having checked the meshes being used for both BP_UsableActor and BP_PickupActor, I’ve confirmed that both meshes have collision primitives. Moreover, my OnUsed, BeginFocus, and EndFocus calls are all events, just as specified in the Blueprint screenshots in this tutorial. Therefore, I don’t think I’m accidentally overriding the relevant functions in BP_PickupActor. The reason why the game fails to highlight my BP_PickupActor instance is quite baffling.

      Feel free to delete the earlier instance of the comment discussing the meshes of BP_UsableActor and BP_PickupActor.

  32. Having checked the meshes being used for both BP_UsableActor and BP_PickupActor, I’ve confirmed that both meshes have collision primitives. Moreover, my OnUsed, BeginFocus, and EndFocus calls are all events, just as specified in the Blueprint screenshots in this tutorial. Therefore, I don’t think I’m accidentally overriding the relevant functions in BP_PickupActor. The reason why the game fails to highlight my BP_PickupActor instance is quite baffling.

  33. Hello! I’m stuck in the part where needed to add the “event on used”. You seem to have output called “character” in there. I don’t. I don’t know where i missed it. Part 1 worked perfectly fine. Anyway i went to my usable actor and added character object in Onused function and then continued part II. The character output become visible. I casted it to MyCharacter but then i cant continue. There isn’t any way to call “add item”. Please, any ideas?

  34. oh boy. I created this tutorial from the scratch and it failed, i loaded your project that is already finished and started adding second part. I don’t know where the problem lies but now there is error in very beginning. I right click on BP_usable actor and press create blueprint based on this. Then i try to get “Onused” and “startfocus” “endfocus” functions from parent but i cannot get it. This is so frustrating. I’ve been fighting for days with inventory-system and after founding your tutorial i still cant get it to work. jeeeeez

    • Hi John, for that you need to right-click the OnUsed entry and use Implement Function. I’ll look at the other issues tomorrow if you need still require help 🙂

  35. Got it working :)! My problem was in the part where we created the blueprint based on actor. I assumed it ment our character and i created blueprint based on that. It messed everything. Not only problem is colliding with book. Sometimes it falls through the floor. I need to adjust it.

  36. When you put something in inventory class does that mean that you can choose an actor and you have all its data in that other blueprint? I’m little confused because i always thought that you need to use interface to pass data between normal blueprints.

    Thanks.

    • There are many ways of tackling a blueprint system. In this scenario I have two blueprints each with their own relevant data. So for example “item durability” like you see in RPGs may not be relevant while still on the floor, but becomes relevant when carried in the inventory or equipped. So I split this into two blueprints and keep a reference of both in the opposite blueprints.

      During the pickup you could pass information to the other Blueprint if you’d like to. For this they added “Expose On Spawn” checkbox on variables in blueprints. If this is checked you can pass the extra variable to “Spawn Actor Of Class” nodes that we used during pickup and drop events.

      I hope that clears things up, otherwise let me know!

  37. Yeah. Very Nice. I have been looking this and trying to get bottom of the cycle this goes. Any change you help us (me) out in this? Maybe draw kinda “state-machine” kind thing that goes circle and there is drawings when the variable pops to other class etc? It would help alot to understand the consept of this system way better than now.

    • Hi AntEater,

      I’m not entirely sure what you mean? Are you asking for a diagram that explains the concept of the system?

  38. I don’t understand how using lenght will get program to understand how to change the currently equipped item.

    • I use the Length variable to make sure we do not go outside of the array bounds. The SelectedIndex variable is the one that is actually used to change the selected item.

  39. Fantastic tutorial. The problem I’m having is that my game is in isometric. I can’t get the outline to work with an orthographic camera. Which parameters should I change in the blueprint to get it to work?

    Thanks

    • Is your problem isolated to just the outlining not working or are you unable to interact with the object all together? (in which case it’s likely the ray missing the target)

      Best way to debug where your trace is going is by using the Debug lines option in the Trace Line node. Set it to Persistent or for duration. (And use F10 to eject from your camera to you can pan around to see what happened with the trace)

      If it’s purely the outline, then make sure your camera is affected by the post process volume. (So checking “Unbound” is checked in the volume of the level, assigning your outline material under Elements) I haven’t used isometric camera before, and I don’t really know of any checkboxes that can turn a post volume on/off for single cameras – but that may be something to keep in mind if the previous steps did not help.

      If none of that works, let me know and we’ll keep digging!

      Tom

  40. Interaction works perfectly, and if I switch the same camera to perspective mode the outline appears. I’m guessing because orthographic flattens the perspective it messes with the depth somehow.

    Thanks for the reply, any help would be greatly appreciated!

    • I loaded an orthographic camera in the character blueprint of https://github.com/tomlooman/ue4-tutorials project and noticed that the post effect doesn’t work as well with ortho-view. In that specific PP material the effect was inverted, so everything had a red tint and mousing over removed the red tint from that specific item. This means that depth is definitely broke/different than perspective view. Now I haven’t done any depth related work with orthographic cameras so I’m afraid this is something for the docs or the forums of UE.

      • Thanks for looking into that for me, I’ll keep at it and hopefully find a method that works. I really appreciate these tutorials, they help a lot.

  41. Hey tom, How do i add thumbnails and weight info and USE that info in UMG? I Have an inventory image i made in photo shop that pops up on the screen when i press tab, Heres a photo:

    http://i.imgur.com/2Wn8ygb.jpg

    And i wanna get that data from my picked up items and store it on there, such as a thumbnail, the name of the item and weight, and options to drop and use items on from that menu. How would i do that all in UMG and blueprints? (I Made the inventory screen popup in UMG btw)

    • Hi Nicky,

      Sorry got not getting back to this issue sooner – while I haven’t worked a lot with UMG yet I’ll try to give you a rundown of what you need based on what I know of UMG:

      Every thumbnail in your inventory will be a widget that holds a reference to the item (or null if the slot is empty) + an “Image”-control to display the thumbnail. The item widgets can probably be aligned using a Grid or Horizontal control that you should create for your inventory widget (the one that holds all items + display the word “inventory” + close button as with your image)

      There are many ways to do this – but hopefully this helps you understand how you could tackle this.

      – Tom

  42. Btw, on the right side of the photo is where all my items go, and on the bottom is my belt where i can equip those items by pressing 1-5 etc. That’s the idea anyway lol But i know you can store additional data to the items by creating variables inside the BP_PickupActor. i just wanna know how to display those attributes in UMG and on a working inventory screen. Thanks tom.

  43. Btw, on the right side of the photo is where all my items go, and on the bottom is my belt where i can equip those items by pressing 1-5 etc. That’s the idea anyway lol But i know you can store additional data to the items by creating variables inside the BP_PickupActor. i just wanna know how to display those attributes in UMG and on a working inventory screen lol

    • I believe I forgot to add a Destroy when dropping items 🙂 Make sure you don’t try to do anything with the item after calling Destroy though! (So remove it from the Array and then call Destroy on the actor you removed)

  44. Hey tom, im kinda confused and wondering if maybe your tutorial is out of order?
    the function for adding an item is shown in the beginning pic, but its not yet created… as i scrolled down to post this i noticed its creation is later on in the tutorial am i right? or is this a different function? im still new to Blueprint so i was just wondering

  45. Tom,

    I’ve gone through this tutorial 2 times on my own project and 1 time now, using your starting point from part 1.

    I am using 4.4.0 and can’t seem to get this to work. I’ve gone through the whole tutorial. It seems like you leave a huge chunk out by not explaining the creation of the On Used event in BP_PickupActor’s event graph. (Second image after your GIF.)

    I get that you have an image there but there is no explanation of it that I can find. I do not have the events you have listed in my PickupActor. Its a child of (based off) your UseableActor, but doesn’t seem to have any of the functions or events. I know you mentioned you have to have a return variable in your functions to get them to show up in children BP’s but I’m not getting them. Was this fixed/changed in 4.4.0?

    I’ve gotten as far as destroying the object I’m hovering over when I press E. My UI does not draw my inventory, and I’m guessing its because my PickupActor event graph is blank, because I can’t get access to those functions or events. I can make a custom event called OnUsed and run another function I’ve made, but I cannot for the life of me get the parent class functions.

    I would suggest video tutorials in the future, or even just more carefully putting down info/naming/phrasing. A lot of peoples problems/hic-up’s are based in the same spots. It could probably help with cutting down on having to answer a lot of the same questions. I’m getting more and more familiar with the BP editor but even still I am having trouble following your steps sometimes. Hope that doesn’t come across as sounding like an ungrateful dick.

    What you have put up thus far for tutorials is great info and very helpful.

    Thanks,

    John

    • Hi John,

      When creating the tutorial I probably assumed too much previous Blueprint experience on the user part. So I left out chunks on event creation etc. assuming people had dealt with that through other (eg. Epic’s or other) tutorials. I did actually make a video tutorial of this, but decided that since I expected people would run into exactly these types of issues I preferred text so I could revisit and adjust where needed. I think there are still some places that could use some extra explanation here and there (if you have specifics please let me know and I’ll see if I can address this in the tutorial!)

      To get back to your problem, are you not seeing “Overridable Functions” in the top-left of your EventGraph view (eg. near all the variables) you could be able to rightclick on that and override the function. (This would be one of the parts that could use some clarification or GIF)

      Thanks for your feedback, it’s definitely appreciated. I can say I learned a lot from making these at launch – and will apply that in the upcoming tutorials. 🙂

      • Wow, insane response time!

        Thanks a lot. I know a video tutorial can be a significant investment of time. (editing, sound, uploading etc etc) But I think they are nice because you can really see a person going through it, so if you aren’t -as- familiar with the editor you can learn that way as well.

        Well I can click on the function and say “implement function” And it moves up to below the Construction Script. I still do not have an event called On Used like in your screenshot. Are you just using a Custom Event named On Used and then running the function? I thought about that but didn’t think it wouldn’t be hooked up to anything. The main problem is I’m not really sure if they changed something with the editor UI in the patches, or if I’m literally just not making something or creating something in the parent, thats when I switched over to your part 1 source files and still did not have an “Event On Used” under my event graph drop down like in your image.

        Here my (your) PickupActor event graph and my (your) UseableActor event graph with the On Used function showing.

        Thanks again and keep up the good work.

        John.

        • Hi John,

          I see where this went wrong. I had to add a return value to make these “events” into overridable functions for child blueprints after I first published this tutorial and not all images got updated! So you are completely correct with your statement that this event is missing, because it no long exists when using a return value in your function.

          I’ll update these images as soon as I can, because this would definitely cause a lot of confusion for people – thanks for pointing this out!

  46. Thank you for this C++ tutorial! After checking both my C++ character’s default max use distance as well as my BP_PickupActor’s replication (It’s a blueprint that’s derived from the C++ UsableActor class), I was able to successfully override the functions of the base C++ custom class while also having functional focus.

    In other words, this tutorial seems to work better than the Blueprint subclassing in the BP-only version.

    MachCUBED

  47. Hi Tom, nice tutorial and very well explained. I have a question than sure by your experience has a logic response. Why you dont add in the “BP_PickupActor” the object parameters for the inventory like the name description to be displayed, why you place it in a different BP? Can’t be the other BP just a generic BP Inventory for just keep the parameters of the inventory (inventory size for example) and its control functions (inventory is full for example ). In your way for each item created you need to edit always 2 BP’s

    • With programming there are always many solutions to a single problem. I decided to make the split to keep future development in mind. For example the InventoryActor should ideally not be an Actor as base class, but use Object as type instead to keep it more light-weight and out of the 3D world (any Actor is considered part of the world, inventory would officially not be part of this) It would be a better long-term solution for replication as well, but for the purpose of the tutorial and prototyping of games it isn’t important enough and using Actor as base keeps things easier when starting out.

      The other reason for this design is that it would be wise to use DataTables for a growing number of items and not maintain a huge number of blueprints. This is something I would like to cover in the future (DataTables are incredibly useful for experience curves and scoring tables too for example!) With DataTables you could modify the two demo’d BPs to retrieve data from the table instead. This is a more advanced topic and well out of the scope for the initial tutorial.

      Generally I’d say inventory systems are not beginner level, I hope to give readers one possible approach and learn how they can break it down for their own unique game. I hope that explains the reasoning a bit 🙂

  48. Hey Tom. Thanks for this awesome Tutorial. Really nice. But i ran into a wall and dont know how to move on. In You “On Used” Function you have something called “BP_BasicInventory Character” I searched through part 1 and 2 of this tutorial and couldnt find anything related to this. I managed to do every other step but this one is a mystery to me wich basically leads to the whole thing not working properly. Another thing is the “AddItem” variable wich i cant create because UE tells me there is already a function/variable called that but i didnt create it. Can u help me with this one?

    • Hi Maizet! The BP_BasicInventoryCharacter is the name of the Blueprint I used in my sample project. You should cast to it whatever name you have given your character Blueprint that holds the inventory logic.

      Hope that helps! (ps. I’ve updated the tutorial to clarify this)

  49. Hello I have a little question about… how did you make the override fucntion intp BP_PickupActor form BP_UsableActor…

    and also I have teh question where the SetSelectedItemIndex event come from in “Drop Item” function in “Character” BP

    • Hi Simon, sorry for the late response.

      To override functions you should see them available in the Variables panel of your PickupActor blueprint. Rightclick the function and click “Implement Function”.

      I see that SetSelectedItemIndex is missing an image, I’m updating the tutorial with the new image. What it does is clamp the value “SelectedItem” between 0 and the number of items in your inventory so the value can’t fall outside of the length of your inventory array.

  50. Dear Tom,

    Sadly this Tutorial is no longer fully functional with Unreal Engine 4.5+ 🙁

    I followed this tutorial and either ran into problems with being able to pick up the item or loaded your Blueprint Version from Github and was able to pick up items, but not drop them.

    Regards,

    Maxunit

    • Hi Maxunit,

      Easiest way to debug this is by putting a breakpoint at the SpawnActor node when you are about to drop the item to the floor. You may have forgotten to assign the class it will use to drop the item, or maybe the position vector is incorrect. Putting a breakpoint and inspecting all of the inputs is the way to go, let me know if you need any more help.

      Cheers,

      Tom

  51. Hey, it’s nicky again. The guy that gave u the idea for the apple hunger system? Well i tried to download it and it didn’t launch for some reason. it won’t launch at all. So i was wondering if u can tell me step by step on how to add when the apple is in your inventory, u press G and u eat it. Thank u so much tom.

    • Hi Nicky,

      The version of GitHub is 4.4, with 4.5 you should be able to compile and launch the project without issue though, I’ve just checked to make sure. Are you getting more messages what so ever?

  52. First of all, thanks for this tutorial, it’s easily one of the more followable inventory ones.

    I seem to be running into similar problems as other people in 4.5 however, specifically the set render custom depth in the BP_UsableActor BeginFocus and EndFocus no longer seem to work. The calls are executed, the debugger tells me that much, but I do not see the outline on the objects.

    I should note that picking up the object does work, I just seem to have fortuitously managed to get my view to look in the right direction, there is just no indication so it becomes a bit hard to know when I can click pickup.

    I have one other question, to see if you have a suggestion for how to manage ‘deselecting’ something. After all, once I turn away and am no longer looking at an item, I don’t want the on-use key to trigger for that actor anymore. It almost seems like there’s a reason to want to set LastUsableActor to null somewhere, so that the moment you stop looking at it there is no LastUsableActor anymore. Reading the current logic I don’t think that happens (nor is the code set up to handle that), but please correct me if I’m wrong.

    • We perform a new raytrace whenever we press “Use” to get the current item being viewed, this works when you turn away from the usable item by returning NULL. So you shouldn’t need to clear the LastUsableActor value for this manually.

      I have tried to run this demo in my 4.5 project that is up on GitHub (link in the article) and I have had no luck reproducing the issue you are experiencing with object highlighting.

      A few things to try:
      In the viewport settings visualize “Custom Depth” and enable Render In Custom Depth on a static mesh in your scene to see if custom depth works at all (it should be white, make sure you move away from the object enough to see the white result)
      When playing with the Render In Custom Depth checked forcefully you should immediately see this object glow, if it doesn’t then something is up with your post process volume (eg. blendable not set up, or Unbound not checked)

      Let me know if you still have trouble with this.

      – Tom

  53. Hi Tom!

    Finally it works! and it works flawless! But I have another question for you. I’ve modify parts of inventory. Create hitbox and i want to set that if I click the hitbox, it will be a “selected item”. \One more time I please you for the help! and I am thanking in advance for the devoted time.

    • You can take the current LastUsableActor variable as a reference, where I store the value when tracing the scene to find anything that is usable and in our center view. Use Left Click event to do a trace (you could re-use the GetUsableActor function for this) to find a box you’re looking at, and store is as a reference “SelectedItem”. That sounds about what’re looking for.

    • Tom… somebody should give you the order for this help. You did a amazing job in the tutorial, as well as helping. Man you rule!

      By the way, I have two last question! (I promise).

      First – in the end of tutorial, i mean when you draw function in HUD. There is a way to array this text or texture (when pickup object) in the scrollbox? I mean – when I pickup item in game, then add texture to the scrollbox? This is my worst nightmare.

      Second – the second question is connected from first, when I add a texture to my scrollbox, and I will click on it, it will be my “selected item” so I can drop it.

      As I promise this Is my last questions, so please help Tom! It will change my life:D

      • Hi, no problem!

        If you plan to do more advanced HUD functionality, I would recommend using UMG for that. You can add a new Button and apply your texture as the background/style. To get the texture for this button you can add a new variable to InventoryItem class of Texture type, you will grab this value and apply it to your button (it will require Data Binding, which is explained in many of the UMG tutorials)

        Here is a UMG intro tutorial (2nd part introduces databinding) http://www.lodzero.com/umg-introduction/

      • Tom I’ve got a question for you. I know that much I require… but would you help me? I’ve done some widget for your inventory system. Actually two widget, one for scrollbox, and one for item button. It is my problem that when I pickup item my scrollbox widget dont update content, therefore I dont see anything on screen. When I plug in HUD widget to “Event Tick” and when I pickup item it creates infinite amount of item button.

        This is screens of widget I’ve done -> https://www.dropbox.com/sh/oiy24k3mdxmqgfp/AADNDO1tItPZyOO-ftwpDAeHa?dl=0

        Please Help!

        Cheers

        • I don’t see any immediate issues with your eventgraph code. However, what you might be missing is that you need to call a modified version of event “Construct” every time the player picks up a new item, this can be handled in the player pawn blueprint after adding the adding to the inventory array.

        • Tom thanks for very quick respond!

          What you are saying makes sense, but not very I understand what you mean saying “modified version of event construct”? you mean a whole function in scrollbox widget?

          Forgive that I am bothering you, but you could explain it to me??

          Greetings!

          • Hi, no problem!

            What I meant by that is that you would make a function that does a similar thing to what you are doing in the Construct so that you can call it whenever an update in the HUD is required.

            – Tom

          • Finally in the end I managed to do it!! Big Thanks Tom! without your help it would fail!

            Like you said I created the function based on what I’ve done in event construct and I add this to function “add item” in player pawn.

            I will upload screenshots how I will have a moment of the time!

            Cheers!

    • Hmm I was afraid of it. UMG to suck! In HUD I create all of function I want… at least I need a box like a scrollbox… and unfortunately I must use UMG for this… which takes me a decades to get this work.

      But I thank you Tom for all advice and hints. Greetings!

  54. Problem found, unbound was unchecked, even though I swore I had checked it………

    Anyway, thanks, now I just have to figure out why the post process isn’t turning off when I lose focus, but that should be straightforward enough.

    One comment and this is regarding your website, I’ve noticed that whenever I click on an image, if my monitor is not wide enough to view the entire thing I literally cannot scroll over to view the cut off part. It will always snap me back to the left part. Also, after I click on an image and close the image, I lose basically all keyboard shortcuts. I can’t do ctrl+f, F5, etc. I’m using Firefox 33.whatever subnumber it is at this point.

    • Thanks for letting me know. I can reproduce this in Chrome as well. I’ll see if I can get this fixed, or switch to another image plugin.

      – Tom

  55. You can add two functions in BP_BasicInventoryCharacter (i called them LastAdddItem and LastRemoveItem) and two variables in BP_InventoryActor to make them stackable. Just replace AddItem and EatFood function to make them work.

    => BP_InventoryActor : http://hpics.li/43eb013
    => LastAddItem (function in BasicInventoryCharacter) : http://hpics.li/32e4db5
    => LastRemoveItem (another function in BasicInventoryCharacter) : http://hpics.li/051c2e2

    => EatFood : http://hpics.li/351fe92
    => AddItem : http://hpics.li/ae4735a

    Hope it helps ! 🙂

  56. Great tutorials, thank you!

    Would you comment on why you didn’t do the inventory system in C++? I am trying to translate this tutorial to C++ as I learn the unreal c++ API and it’s pretty tricky so far.

    • Thanks! The reason why I did this part in Blueprint at the time was simply because a lot of people (including myself) were interested in learning how to make games using Blueprint more than C++. There is a bigger audience for BP, hence why I made a BP version of the C++ part 1 of the series later on.

      Were I to build a full inventory system for use in one of my projects I would pick C++ for the framework of it and use Blueprint only for the implementation details to tie content and code together. This is how I handle most features for Switch as well.

      – Tom

      • I thought that might be the case but I wanted to make sure there wasn’t a specific reason regarding the implementation. Thanks!

        I noticed an earlier comment by you regarding UMG and an interface. Are there any plans to extend the inventory to accommodate an inventory UI?

        I followed the C++ version of part 1 and ended up following the second part as is with blueprints. I’m having some trouble and would greatly appreciate some advice if you can find the time:

        The post process isn’t showing up and I also can’t pick up the items. I set up the volume in the world and I believe the settings are correct.
        http://imgur.com/2b4Tdzn

        I also have the keybindings set and have gone back through to make sure everything is set up as yours is. I am using 4.6.1.

        Also, I made sure to thoroughly review your suggestions for troubleshooting. It seems those are all taken care of. I can’t seem to figure out how to make the line traces visible for debugging purposes. Do you have any suggestions as to where I can look for errors?

        Thanks again!

  57. Figured out part of it. I had to re-parent my character BP to the C++ version (this project started from a BP template).

    So, yay, items are highlighting! However, I can’t seem to pick them up. I added some debug text and found out that the Use_Implementation() is never being called. My ‘E’ key is bound to ‘Use’. I’m not sure what the _Implementation() part is but changing it to Use() gives me errors.

    Any suggestions are welcome, thanks!

    • Hi Broadway,

      The _Implementation is part of unreal’s networking implementation. It means that it is a server side function and does nothing special if you are a singleplayer game.

      You should never call a _Implementation function directly and instead call the original function name. eg. “Use();”

      _Implementation is only used when you marked the original function with “server” eg. UFUNCTION(WithValidation, Server, Reliable)

      I hope that helps you figure it out. Let me know if you have any questions.

      – Tom

  58. That makes a lot of sense. The comment seemed to hint at that but I couldn’t make sense of it. Thanks!

    I can’t figure out why the item is not being picked up despite being highlighted. I added a print string in the pickupActor BP and it is not being called. In the C++ tut I see:

    InputComponent->BindAction(“Use”, IE_Pressed, this, &ASSFPSCharacter::Use);

    But when I select ‘Use’, right click, and hit go to definition it takes me to the header file where it is declared. There is no definition. I think I may be misunderstanding the code but I figured it was the best place to start for debugging. Any suggestions on what to check?

    Thanks again!

    • “But when I select ‘Use’, right click, and hit go to definition it takes me to the header file where it is declared. There is no definition. I think I may be misunderstanding the code but I figured it was the best place to start for debugging. Any suggestions on what to check?”

      This is because Visual Studio / Visual Assist don’t understand the UE magic compilation of Use_Implementation() where the definition is Use() without _Implementation. This is Unreal specific so the generic tools don’t know how to handle this, but your code is correct.

      A few things to consider: Make sure the “Use” is correctly bound in the project settings under Input. Secondly check if the Use function is actually finding an object in the raytrace, so check for NULL there. Your best bet is to use Visual Studio to step through using a breakpoint (You will need to compile the game using “DebugGame Editor” instead of “Development Editor” to get accurate debug information while stepping through)

      Hope this helps!

    • Hi Ashley,

      What you need is a class definition (purple) to exist inside the InventoryActor blueprint. Look for the “PickupClass” variable in the tutorial itself:

      Make sure that you will it with a value of the class you wish to drop after compiling it.

    • I seem to get this error as well even though I definitely have the PickupClass set. The “Get” outputs an Object Class and not an Actor Class, which is what the Spawn Actor needs.

      • Variable may just need setting as public I think. Latest UE4 is a lot tighter and I think older versions didn’t enforce it. In a lot of tutorials, people don’t make them public but I often need to make them public to see them. Will check it when I get the chance.

        • Right, they are changing some of that behavior. I’ll need to update the tutorial if this is indeed the case. Thanks for pointing that out.

    • Could it be that the Usable Item should be based on an Actor and not Static Mesh Actor in the C++ section? Because I decided to follow another tutorial that is BP only to test it out, and if you make an array based on Actor’s, hovering over it says, “Array of BP_Inventory Actor C Reference” (which is what your project states in the BP project files), where as if it’s based on a Static Mesh Actor it says, “Array of BP_Inventory Actor References” which is what shows if I follow your C++ Part 1 then this up to that point.

    • And because spam seems to be my thing, try making the variable in question public by clicking the closed eye (looks like a little squiggle next to the variable in graph view) on the PickupClass and let me know if that helps. Figuring stuff out as I try multiple tutorials and trying to give feedback on possible solutions.

  59. I started with the C++ method by the way. When I look at your project (one I downloaded a while ago) which seems to only show the BP method (CPP method folder doesn’t seem to have much in the BP’s), the Inventory Items array when hovered over says, “Array of BP_Inventory Actor C Reference” whereas mine says, “Array of BP_Inventory Actor References”.

    My project runs on 4.6, yours on 4.5 so wonder if the implementation of those nodes has changed? Going to see if I can find time to run through the nodes or try to redo an inventory system from scratch aha. Even if I don’t know how xD

    • Hi Ahadiel,

      Sorry for the late response! I hope I can still be of help.

      There shouldn’t be any breaking changes between 4.5 and 4.6 (I haven’t checked for this code specifically, but I haven’t seen any migration problems in any of my projects)

      The “C” in the variable name is likely because of the way blueprint is compiled/name vs. C++ classes. That shouldn’t be your problem here.

    • Yeah, I think it was because the variable might not have been set to public. Didn’t see that in the tutorial. When I first tried UE4, I never had the issue, but going through Epic’s official inventory tutorial, and realised that variables need to be made public to work cross-blueprint. Can’t delete my comments on here I think, so just end up spamming a little as I figured more out aha.

  60. I moved your project into 4.7.2 and i have run into one problem. The Post process overlay when you highlight an item. It no longer highlights the edges. It now highlights the entire model. It’s most likely this happened when they changed how the post process effects work in the updated engine with all the new lighting changes for open world. I’ve done very little work with post processing effect so it may be some time before i hammer out what went wrong with it. So any help would be great.

    Just so everyone else knows. This project can be updated to 4.7.2 and works just fine after fixing a few broken pins and some other basic things that come with an update.

    • Hi BinaryHelix,

      I updated the source to 4.7 in the github repo. I did not encounter any issues myself though. Did you have any specific break for you? (outline post-effect still worked fine too after 4.7 conversion)

  61. Hey I am having trouble with this tutorial for 4.7.2/ Is there any updated version? I fixed the problem with AObjectImplementation (Instead if FObjectImplementation) and a few other syntax errors, but I am running into a problem with blueprints. I cannot find the BP_PickupActor>On Used blueprint. I can only create a blueprint for BP_PickupActor>Event Graph and it does not work. I cannot call the function “Add Item”. Very Stuck!

    • Hi Aggreisvenapk1n,

      I tried this in 4.7 and it’s working fine. So your problem must be elsewhere. “OnUsed” is a function/event made in part 1 of the tutorial. Please make sure that code/blueprint (depending on which part you followed along with) is correct. OnUsed should show up as a function to implement (it will do nothing by default)

      Let me know if you have any further specific questions.

      – Tom

  62. Hi,

    I have the exact same problem as mentioned by Aggreisvenapk1n and some others here in the comment section.

    I’ve created a BluePrint based on the UsableActor BluePrint but I am not able to override the “OnUsed, BeginFocus & EndFocus” Functions within the PickupActor BluePrint. They don’t show up while they are created (When trying to re-create those functions in the PickupActor BluePrint I get … Is used by another variable or function)

    I am using Unreal Engine version 4.7.2. Maybe something has been changed last patch?

    Kind regards
    Rowan

    • Hi Rowan,

      I checked 4.7 and that should not affect the tutorial. Please double check that they have a return value (so they show up as functions) and that they are exposed using the UFUNCTION() (in case you were following the C++ variant)

      – Tom

  63. Any plans of writing a C++ version of this part? I figure there aren’t many requests for this, but I’m trying to learn C++ more-so than BPs as it’s a skill set that is useful outside of UE. Whereas, BPs on the other hand, are proprietary… Unfortunately though, it seems like UE4 related search results are saturated with a ton of BP stuff and very little on C++.

    • There is more C++ coming your way! I can’t tell an awful lot about it yet, but you should hear more of this in the coming weeks.

      – Tom

  64. Hey tom is there a way that i can for example, press alt and then the name of the item appears?
    If there is , how can i do it?
    Thank very much man!

    • Absolutely, you’d use UMG for that and simply toggle a boolean in your HUD to draw/hide a loop that moves over all items of a specific class in your scene. (GetAllActorsOfClass) to project your HUD text into 3D you will need something like “project vector” node in blueprint to make sure it covers above the item in the scene.

      Hope that helps you get started.

      – Tom

    • Thanks for the reply Tom. I am very newbe at this so i’ll have to create a BP HUD > create a variable bollean > at this point how do i ”draw/hide a loop that moves over all items of a specific class in your scene”? > transform the 2D text to 3D > and here i have to discover how to setup the text above the item?
      Is this make sense?
      Thanks again!

      • If you don’t wish to draw them you can use that boolean as input to a Branch-node, this outputs TRUE and FALSE to draw or ignore your items to draw.

        – Tom

  65. Hey, awesome tutorials; very nicely laid out and presented.

    However, I’m pretty sure I’ve followed the tutorial perfectly, but I can’t seem to interact with the PickupActor. I can interact with the UsableActor, it gets destroyed on line hit.

    • There is a couple of steps to consider. The character’s ray trace must have something to collide with in your object, it must have the correct collision channels set up, if must inherit from UsableActor. Those are the first three to check. Hope that helps, otherwise can you give more specifics?

      – Tom

  66. great tutorial for a basic Inventory system but I do have some questions as I have a hard time understanding how you would be able to add different kinds of pickups.

    making a copy(duplicate) of both: BP_InventoryItem and BP_PickupItem will not make it work as a pickup as you have hardcoded the way the player stores the items (to say so)

    The whole blueprint pickup system is based on BP_InventoryItem and BP_PickupItem
    for instance in your character blueprint you’re casting to BP_PickupItem -> so making a copy/duplicate and renaming them both will not make it work at all as you will not be able to make them ” pickable”

    as I see it now this will make one pickup work nothing more nothing less. If you were to simply copy/duplicate BP_InventoryItem & BP_PickupItem and change their meshes nothing will work and getting them to work means re-working the core of your system.

    To me it seems this isn’t the way it should be done and will require a lot of work to get it to work with new/other pickup items.

    Would you be willing to add a short tutorial on how to get new pickup items to work? as this

    “”If you want to create additional items such as a weapon you have to create child blueprints for both BP_InventoryItem & BP_PickupItem. Update the default values for both objects to your new blueprints and assign a new model.””

    isn’t true…

    • There is a big different between making a copy/duplicate and making a child blueprint. If you inherit your new Blueprint from the pickup and inventory classes (“R-click -> Create Blueprint based on this”) you can they inherit all previous logic and are immediately interactable.

  67. Hi tom

    Yes i’m sorry (never knew “create blueprint based on this – right click” was the same as child blueprint) but this system will still cause issues when you drop the item from your inventory. It will still drop the main (parent) class item/blueprint and not the child? (at least at my side)

    I will try to re-do this system one more time to see if I made any mistakes but

    • You must update the variable PickupClass in your new inventory item. That determines the type of object dropped.

      The intention with this system is to generate all this by using a table that holds a few columns so it’s easy to add new items. I never got that far along though, so it may sound cumbersome to think of needing to set up so many BP variations.

      – Tom

  68. Thanks for taking the time to answer all the questions here including mine.

    I have it fully working now including networking/multiplayer. I did change the HUD items with a UMG based one.

    Thanks again and keep up the great work.

    • I have one question though….why are we spawning a new actor everytime something’s added to the inventory? I think we can store the same information in an array at runtime. Or will that actually be costlier than spawning an actor in the game world?

      • We could use Components instead of Actors for the carried items, it was a matter of simplicity and engine state at the time of 4.0 that I used Actors. Components are likely more efficient to replicate on the server too.

        – Tom

      • Hey Tom!

        How are you doing? So I managed to make a working prototype of this system using an array of a USTRUCT to store the properties of the Pickup 😀

        In addition, I also derived an actor called APickupBase from AUsable, and am using the APickupBase as the base actor for all pickups; the idea here being we can have another class AUsableBase for things like doors, levers, etc.

        Would you care to have a look at the code, and let me know if I’ve got it right or managed to FUBAR it 🙂

        Thanks!

        • Hi Mukund,

          Sounds like you got it right! Have you done anything for replication with the structs yet? I’m not sure how well structs are for replicating only partial data between the server and owner of the item. If you’re not concerned with networking yet, I’d ignore it for now 😉 Otherwise you could compare it to using ActorComponents because they definitely replicate properly/efficiently.

          – Tom

        • Hi Tom!

          So I tried out the replication aspects of this actor, and, it actually works, but with one caveat: I have added a replicated StaticMeshComponent, which works fine if I’ve initialized its Static Mesh variable in the editor. But when I dynamically spawn and set the parameter, it seems to have no effect and a default mesh which I set as the default value in the blueprint keeps showing up. Any clue as to why that may be happening?

        • Never mind; I figured out the solution: I converted the variable driving the setting of the parameter from a replicated to a repnotify and used the repnotify function to trigger the change. Worked like a charm!

  69. Hello, thank you so much for your tutorial. I knew I lot of things with your help. I can’t realize one thing. In your blueprint you added base eye height as third number. (As far as understand vector is object with three floats) but I can’t add vector to float as on your picture. Bleprint only suggest me sum only one float with vector and I can’t add pin in this node. Thas why pickup actors drops on right side of character.

    It would be great to realise all this stuff as c++ only library.

    • You’ll need to make the float into a vector and add the float into the Z channel of it. Should appear when typing in “make vector” in the blueprint context menu (right-click)

  70. I have done this in a third person and it works.
    My problem is that unlike first person you don’t look directly at the object so if the object is small its hard to look at it and pick it up.
    What will be a good solution for that?

    • Hi Tom 🙂

      One way of dealing with this is adding a collision volume in your pickup blueprint, this can be any size larger than the original object (you could even let auto scale based on the GetBounds from your staticmeshcomponent, and use bounds * X to get a larger selection outline) This collision shape should only respond to the pickup channel and have all other collision disabled.

      For an automatic approach you could even do this only for small objects, eg. the larger the object (by checking the bounds) the smaller the X multiplier (down to a minimum of 1.0). Doing this automatic through Construct-script in BP is totally optional, just having a collision shape like a sphere or box that overlaps the ray’s collision channel.

      – Tom

      • So what happens when I have a couple of items close to each other wont the collision volume collide with each other (no pawn intended)?

        And I know its stupid I just now realized we have the same name :).

        • They won’t collide since they are set to ignore all channels except overlap the ray-trace channel of the player (and collision can be set to PhysicsOnly so only overlap and raytrace queries still work)

          And yeah we do, feels like I was replying to myself 😉

  71. Great Tutorial, but I can’t find the “PP_OutlineCustomDepth” in my Project. I have enabled Starter Content. I hope you can help me.

  72. Hi Tom,

    Thanks for your tutorials, some of the best out there no doubt.

    I followed your C++

    I followed your UsableActor tutorial in C++, and now I’m working my way through part 2 here.

    I’m having trouble with the OnUsed function within the BP_PickupActor blueprint. (http://i.imgur.com/pcfdFG3.png?1).

    The cast is basically failing to the BP_PlayerCharacter blueprint. That blueprint is the equivalent of your “BP_BasicInventoryCharacter” (i think).

    Any idea where I could be going wrong? Within the playercharacter blueprint or the bp_pickupactor blueprint? I’m lost!

    Jack

    • Sorry, ignore “I followed your C++..”

      Also, I just want to add, If I don’t have “Cast failed” within the cast node, connected to the return node, I get an error on the cast saying “Info The execution path doesn’t end with a return node. Cast failed.”. Attaching it to the return gets rid of this error, however it still fails each time when I test it.

      Might it have something to do with how I created the BP_PlayerCharacter blueprint (BP_BasicInventoryCharacter)? To create this, I simply created a child blueprint of my PlayerCharacter C++ class, (your Character class in the 1st C++ tutorial).

      I hope I’m making sense here and I really appreciate any help!

        • Hi Dan,

          Thanks for the response.

          OnUsed is used by the BP_PickupActor, as you can see here: http://i.imgur.com/pcfdFG3.png.

          Unless you’re asking for the c++ implementation?
          UFUNCTION(BlueprintImplementableEvent)
          bool OnUsed(ACharacter* character);

          Sorry If I misunderstood.

          Default Pawn Class is set to the parent c++ class of BP_PlayerCharacter. PlayerCharacter is the C++ class, BP_PlayerCharacter is the blueprint class.

          Is the BP_PlayerCharacter blueprint meant to be initialised? To test this, I added a “Print String” to its “Event BeginPlay” , to see if it would print anything – nothing came up.

          As you can probably see, I’m pretty new to this, thanks for the help!

          • “Sorry, misread your last comment ? Wanted to see all the code from the tutorial and how you implemented it, just to make sure it matched up with Tom’s tutorial ? Tom tends to be busy but he should reply when he gets a chance ?”

            No problem, thank you Daniel. Look forward to hearing from him when he has time. I checked the code last night, all is identical. I’ve only added extra movement functions, nothing in relation to Tom’s code.

            Thank you for responding 🙂

    • Hi Jack,

      Sorry it took so long 🙂 Let’s have a look…

      First thing to check is the input value of the OnUsed function. You can do this by hovering your cursor over the input pin of the cast-to node while executing with a breakpoint (right-click the cast-to node and add breakpoint) that should give you a class name so you can make sure it’s not NULL and is of the expected type BP_PlayerCharacter.

      Hope that helps, and otherwise we can move from there.

      – Tom

      p.s. It’s always best to cast to the lowest possible class, eg. if the AddItem function exists in our C++ version of character, then there is no need to cast to the higher “tier” BP_PlayerCharacter inside of this OnUsed function. When working with more complex layouts you’ll notice that’s a much easier workflow to handle change when only casting and using the bare minimum.

  73. First thing I want to say is that this is an awesome tutorial. This was the first one I was able to complete out of many that I have tried before and meets my needs perfectly. I just have one problem with the physics, which I would prefer instead of tracing to the floor. However, when I set the simulate physics to true, I am unable to pick up the actor, while I am able to when simulate physics are set to false. I am sure there is something simple I’m missing, but I have not been able to find it. Thanks again for this awesome tutorial.

    • Encase anyone runs into this issue Luke pointed out I found if you go to your UseableActor look under addcomponents and click staticmeshcomponents to see the details panel under the collision tab check to see if its set to default. if not try it with physics on to see if you can pick up your object.

  74. Hello, Tom.
    Great tutorials.
    Can you help me, please: how to implement different outline color for different objects;
    for example- for cube green color, and for sphere red color.

  75. Hey Tom,
    I am looking to display my picked up item on the HUD during gameplay. For example, I pick up a grenade, and I want to see that I have a grenade in my 4-slot inventory on the bottom left of the screen.

    • You will need UMG for this, showing/hiding Image slots (your Grenade Icons) and keep track of the number of grenades you carry in the Pawn class for example. There are many ways of doing this to be honest, really depends on your overall game.

      – Tom

Leave a Reply