Items Not Adding to Inventory

Hi, I’m trying to make an inventory but items aren’t ever being adding to it, the code executes all the way through and returns successful, but nothing gets added.

Here’s the ‘AddToInventory’ function Imgur: The magic of the Internet

I even tried doing it a second way but it didn’t change anything

Add Node … execute pin

Hello again, haha, no that’s not it, I disconnected that node to plug in the second version to see if it would work that way, but it didn’t change anything, I put an imgur link to the full original function that you saw the other day

Does anyone know what’s going wrong? I still haven’t figured it out and everyone I’ve asked doesn’t know either

Pop in print strings along the logic flow. Narrow it down. Once you find the culprit drop a reply.

I’ve just tested it with prints at every point, and it’s definitely finding the right sub-inventory and item indexes and info, and finding the right path to follow based on if the item is found or not, and stackable or not, but nothing is changing in the ‘Slots’ array of the sub-inventory, so it’s the ‘Add’ and ‘Set Array Elem’ nodes that aren’t doing anything, but the function is still executing as a success.


Is anyone able to help me please? My entire project has been halted until I can fix this, I haven’t been able to get anything done for the past week now :frowning:

Hi, I seem to be using a very similar inventory setup as you (I guess realistically it’s a pretty common way of doing it). Out of curiosity, within the section commented “Doesn’t have item, adds to inventory” why are you first getting an element from the inventory array there? Why don’t you just execute the Add node straight off the array there instead of using the GET > Break?

Alternatively, you can use “Set Array Elem” to set a particular element in the array and pass it whatever your item is.

Hi, I’m breaking it because my ‘Inventory’ variable is an array of ‘Sub-Inventory’ structures, rather than an array of items themselves, these sub-inventory structures have the array of ‘Item’ structures in them along with other sub-inventory specific variables. It’s for streamlining making the inventory UI mainly, I want my inventory to be split into categories, such as ‘Weapons’, ‘Equipment’, ‘Consumables’, etc…, and each one of them has a list of items pertaining to that sub-inventory. This way I can set limits on individual sub-inventories, like for example consumables I don’t want an inventory limit, but weapons I would limit to 8 for example, but yeah, in short it’s just because the item location is an array inside another array of structures

And as for the ‘Set Array Elem’, I used that node in the second attempt picture, but it changed nothing. It’s also being used in the part commented “Add quantity if item is stackable and player already has one”, and that one doesn’t do anything either.

I see. I wanted to have separate management of my different types of items as well, but I ended up making different inventories within my main inventory component for that, and it’s working pretty nicely (so, I have arrays for AmmoInventory, PrimaryWeaponInventory, SecondaryWeaponInventory, HealingInventory, etc. It sounds like a headache to manage but it’s not bad at all and I wanted it this way to have full flexibility to re-design the UI for each category any time I want to). My UI is fairly simple too.

Quick question, in that “Get” that you have there from the Inventory array, are you using Get Ref rather than Get Copy? If you’re using Get Copy, you might be adding to that “dummy copy”. Not sure if I’m right on that, just something to look at!…opy/index.html

I’M A DUMBASS! Thank you so much! I was using Get (a copy), I’m still learning blueprints and I completely forgot Get (a ref) was even a thing, I’ve never had to use it before, haha, thank you!

And that sounds like a pretty good idea, if that didn’t just fix it I might’ve redone it like that, haha

Good night I am new to unreal engine 4 and I made an autosave system and checkpoints in my first level but I go to level 2 I save I exit and load the game and it opens me in level 1 in a random location as I do for the system save and checkpoint work at both levels what steps should I follow

Sorry, save systems are beyond my capabilities, you’re gonna have to make a new topic

Ah man! I’m happy to hear that was it. Yay, I helped someone! I’m no expert, maybe only a few months ahead of you in learning UE.