Blueprint Inventory System Help

I’m in a rough spot here and these questions may be a bit too complex but I’ll give it a shot anyways. I am creating an inventory system with blueprints and I’m having trouble mainly on how to integrate it with UMG. I followed this wiki guide for the basis of the system and then tried to incorporate that with this UMG video tutorial for the UMG part.

How I would like to have my system work is that the player will have multiple inventories, each with a different number of slots and other settings. An inventory has a maximum slot count with each slot holding 1 item, there is no weight limit to my inventories unlike the guides. There would be four main inventories: pants, jacket, backpack, and belt. The player will only start out with pants and jacket but can find the other inventories later. They can also be upgraded to have more slots.

Now for the problem: I don’t know how to make the UMG elements representing the inventories be able to “expand” when they change. For instance: you find a jacket that has four slots and your currently equipped one only has two slots. When you put it on you get extra space, so the UMG needs to update and add two more slots. I am following the formula in the UMG video tutorial where the UMG inventory is composed of a uniformgridpanel of InventorySlot UMG blueprints. How can I add more of these InventorySlot’s to my inventory when it upgrades? Each InventorySlot is a variable in the GameHUD UMG blueprint. Could I add a whole bunch of them to the GameHUD and make all the unused ones invisible until the inventory is upgraded?

Most of the blueprints are the same as in the tutorials except for a few values. If you would like to see a certain part please say so and I’ll get a picture of it. Thanks in advance!
[HR][/HR]
This isn’t as high of a priority as my first question, but whenever I try to pick up an item that can stack I’m getting all these errors:


[2017.06.14-01.27.31:003][933]LogScript:Warning: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
	BaseInventory_C /Game/ThirdPersonBP/Maps/UEDPIE_0_ThirdPersonExampleMap.ThirdPersonExampleMap:PersistentLevel.BaseInventory_C_0
	Function /Game/Blueprints/InventoryBP/BaseInventory.BaseInventory_C:AddItemToInventory:0686
[2017.06.14-01.27.31:003][933]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
[2017.06.14-01.27.31:003][933]LogScript:Warning: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
	BaseInventory_C /Game/ThirdPersonBP/Maps/UEDPIE_0_ThirdPersonExampleMap.ThirdPersonExampleMap:PersistentLevel.BaseInventory_C_0
	Function /Game/Blueprints/InventoryBP/BaseInventory.BaseInventory_C:AddItemToInventory:06E1
[2017.06.14-01.27.31:003][933]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
[2017.06.14-01.27.31:003][933]LogScript:Warning: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
	BaseInventory_C /Game/ThirdPersonBP/Maps/UEDPIE_0_ThirdPersonExampleMap.ThirdPersonExampleMap:PersistentLevel.BaseInventory_C_0
	Function /Game/Blueprints/InventoryBP/BaseInventory.BaseInventory_C:AddItemToInventory:07A5
[2017.06.14-01.27.31:003][933]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
[2017.06.14-01.27.31:003][933]LogScript:Warning: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
	BaseInventory_C /Game/ThirdPersonBP/Maps/UEDPIE_0_ThirdPersonExampleMap.ThirdPersonExampleMap:PersistentLevel.BaseInventory_C_0
	Function /Game/Blueprints/InventoryBP/BaseInventory.BaseInventory_C:AddItemToInventory:0800
[2017.06.14-01.27.31:003][933]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
[2017.06.14-01.27.31:004][933]LogBlueprintUserMessages: [BaseInventory_C_0] Item added to inventory at index: 1
[2017.06.14-01.27.31:004][933]LogBlueprintUserMessages: [BaseItem3_425] Item was added to: BaseInventory_C_0
[2017.06.14-01.27.33:120][187]LogScript:Warning: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
	BaseInventory_C /Game/ThirdPersonBP/Maps/UEDPIE_0_ThirdPersonExampleMap.ThirdPersonExampleMap:PersistentLevel.BaseInventory_C_0
	Function /Game/Blueprints/InventoryBP/BaseInventory.BaseInventory_C:AddItemToInventory:0686
[2017.06.14-01.27.33:120][187]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
[2017.06.14-01.27.33:120][187]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
[2017.06.14-01.27.33:120][187]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
[2017.06.14-01.27.33:120][187]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem_251 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem_251 is pending kill
[2017.06.14-01.27.33:120][187]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem3_425 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem3_425 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem3_425 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem3_425 is pending kill
[2017.06.14-01.27.33:121][187]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem3_425 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem3_425 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem3_425 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem3_425 is pending kill
[2017.06.14-01.27.33:121][187]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem3_425 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem3_425 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem3_425 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem3_425 is pending kill
[2017.06.14-01.27.33:121][187]PIE:Error: Error Blueprint Runtime Error: Attempted to access BaseItem3_425 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem3_425 is pending kill from function: 'AddItemToInventory' from node: HasPartialStack in graph: AddItemToInventory in object: BaseInventory with description: Attempted to access BaseItem3_425 via property Item_3_ABE4676F46D081F8BC1831A10D2D98AE, but BaseItem3_425 is pending kill

Hi,

I think “PendingKill” error happens when you are trying to access an object that has been marked for garbage collection, but not have been actually destroyed yet.

Do you by any chance destroy your “BaseItem” before you actually trying to use it? A useful way to prevent this error is to check if the object you are about to access is valid. You can easily do this by using the “IsValid” node. You should only proceed using your checked object if it returned as valid.
Put a “PrintString” node where it fails and try to observe in which cases your object returns as a “PendingKill”.

With the pending to kill error, I’ve narrowed it down to the item in the BaseInventory object not being valid. Whenever I pick up an object I add a new inventoryStruct to the BaseInventory, then delete the object which is in the world. Is it trying to reference the old object and not the new one in the inventory?

Yes, I believe it is trying to reference the object you delete. Try to turn off collision and visibility on the object instead of deleting it, or try to teleport it somewhere. Alternative solution would be a data based inventory, where you do not actually store the object but only the properties of it.