How to create chest storage

Hello,

I followed this tutorial on creating a simple inventory system in UE4.

I tried expanding it to include a chest storage so that I could place my items into the container. So if my character only had so much inventory space I could off load into the chest.

I have spent a whole day trying to get this done but no luck, I have done a ton of googling around and there are really no tutorials or examples on how to do this. A little frustrating since I feel like it’s a basic thing to have in a game.

my blueprint matches the wiki tutorial from above so I wont post my scripts because it’s exactly the same. I looked around for other inventory tutorials but this one was the most clear to me.

Thanks for your help

To put it into practical terms, are you trying to create a Minecraft situation where you have a personal inventory and you want to move items into a chest? If so it basically works the same way I imagine you have your inventory set up right now. Your player has an inventory, your chest has an inventory, and to move the you remove the item from the player’s inventory and add the reference to the chest.

Your Inventory setup should be modular (a component). You add the component to any actor and they now have a functional inventory interface. You call a RemoveItem method that returns an InventoryItem (output pin). You take this InventoryItem reference and add it to the other actor’s InventoryComponent via AddItem’s input pin.

See Adding Components to an Actor in Unreal Engine | Unreal Engine 5.1 Documentation to learn how to deal with components in Blueprints. It is worth noting that I don’t believe you can create a custom component solely using blueprints, but you can simulate a similar effect by using interfaces.See https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/ to learn how to use Interfaces.

Thank you for your quick reply.

I figured that was the route I had to take but man it’s much harder then I thought. So far my system works by having another button show up on my inventory action menu when I’m near my Chest BP (I just duplicated the canPickupBP from the tutorial i used in my OP).

Then I hit the button to deposit into the chest inventory which I also created by duplicating the Inventory setup from my first person character. This is where it gets tricky. you hide the chest inventory menu unless you are near it. This is done with collision box on the chestBP actor and a reference to the item actor.

Right now the button just grabs the chest world location and drops the actual item on to it from my character inventory. I hide the item actor but leave collision on so that when I want to transfer the item(canPickupBP actor) back into my inventory I just pick it up like it was off the ground. use a bool to disable the grab key when near the chestBP.

My biggest problem I have now is storing multiple items inside my storage and retrieving them correctly back. I think my problem right now has something to do with my +/- for inventory slot numbers. It doesn’t work with more then 1 item.

I will post back here if I come up with a solution in the next few days. If so then storage is basically set and I can detail it out more for others here.

Yes I’m using interfaces and calling message events and all that other jazz you mentioned. I really wish this guy who did the video serious would also have one where we could expand it out to other items.

I’m detailing this so that others can see what I have tried and know that it’s not easy because this is the main tutorial from Epic for inventory and getting storage is the next step for this.

UPDATE!

-Here are the screen captures of my setup and how it works. The above post is correct on how you approach doing a chest system. I will leave my original comment to show my progression. Basically my problem with multiple items came from not setting the construction script on the item itself. Everything works just like the inventory on the character but in the chest and I can have multiple items stored and retrieved no issue, like a real chest!

If you get stuck I would recommend walking away for a little bit and thinking about it. that’s how I figured it out. I hope my images guide you in the right path.

And the last few.

Continued…

Hey I’ve been following those screenshots of yours. But, It does not work. Would you mind do a tutorial video about it? I don’t think it will take that long yeah?