I have an inventory system that I made by following a tutorial but I’m having trouble trying to figure out how to add items to it. I already have an interaction system where I can press E on an item to get it to fire a function, all I need to know now is figure out how to add items now.
(Someone said I needed to use a TMap but I wasn’t sure if I had to delete my original inventory system to get that to work)
This is my inventory
This is a repost btw because it’s been like 10 days since I asked this
Since your inventory seems to be an array of actors, it’d be a matter of adding an actor who is the target of the interface message to the inventory array. Have the Start Interact return an actor’s (here, BP_Beans) reference (modify the interface function to return actor refs), and have the player add the item to their inventory.
Hey thanks for the reply, I made the start interact function return an actor but now I’m just confused on what node I would use to add the item to the inventory? If you could maybe send a screenshot example of how that would look it would be a lot easier to understand (if you can’t that’s fine too)
Oh yeah I probably should’ve elaborated on that (bare with me here because this is my first time making an inventory system so I’m not even 100% sure if this is how it works) But I have a header file called item and it holds all the data for every individual item such as the thumbnail for example, I then have children of that class that has data for a specific item like the BP Food Item (In the inventory component array). Then all these items get initialized in an inventory component that’s in the player character I think? I’m just gonna send screenshots if none of that makes any sense. ( I followed a tutorial on how to make this if you couldn’t tell)
I’ve been trying to follow along with your screenshots but when I try to add the “self” node it won’t let me because the graph is read only, how did you turn that off?
This is the interface. The implementation of its functions goes into the Item actor (where you saw an error earlier on). See my 2nd screenshot - I am doing it inside the item itself.
This is also the place where you could decide whether this item can be picked up to start with, and what happens to it after. Any item class can implement its own logic - you would not want to pick up an entire tree and put it in the inventory, for example. Perhaps a tree would return some data to indicated that, or even return some edible fruit instead.
Sorry I’m just slightly confused because in your “Pick Up Item” function it says the target is BPI Interact and my target says BP Beans which doesn’t seem right. I also don’t seem to have a reference to the “Pick Up Item” function in the player graph which I don’t know how to get.
In the menu. Double check my screenshots - this part belongs in the Inventory. It’s the inventory that stores items, right? Not a menu. And you’re dragging the blue wire on the wrong pin.
Oh yeah I named my blueprints kind of poorly (I followed a tutorial and that’s how the guy named his blueprints) I wasn’t sure if I was able to add functionality in an inventory component? But the main menu is the UI that shows the actual inventory here.
Again, this does not belong in the menu. Your inventory is right here:
In the player BP. The inventory should be responsible for managing items. Why is the Main Menu even involved in this to start with? Consider restructuring it so it makes logical sense unless you have a good reason for handling it this way, ofc.
Regarding the error - it explains the type mismatch; ensure you’re adding a matching item type to the array. Have the interface return Actor type for now, same for the inventory array.
Sorry for the late reply I’ve been trying to wrap my head around this, I was under the impression that the menu was the inventory, but I suppose not. I was trying to get in the inventory component like you showed me but it turns out I have it set up in c++ not blueprint(So I don’t think I can edit this in BP or else it’ll mess something up but I’m not 100% sure, I also tried turning the class into blueprint but I got some errors).