Adding Item to Object Array via Blueprint

My Problem

I have been working on a game I plan on adding a massive looting system into. I would like to make this dynamic and fun to use, and have been looking through the forums and AnswerHub, but many of the fixes are for C++, which I am quite unfamiliar with.

I have gotten it to work about 25% of the time for each method I use. For example: *I have the level setup to add an Upgrade Pack from a part of the level into the player inventory as a test. As a result, about 25% of the time the tile in the inventory menu will read all of the information from the UpgradePackA parent actor object; the other 75% of the time it is either blank all around, or it says None as the title and nothing else. I have tried spawning the actor when adding it through the UpgradePackA blueprint with a pickup event, also adding Self to CurrentEquipment array of objects. Now, the weapons which I have placed in the level add themselves using the Apend node with connectors going to the pre-placed weapons object references through the Level Blueprint.

Some of my Attempts

[AnswerHub: Add selected actors to array ^][1]

[Video of my Project and Some of the Blueprints ^][5]

UpgradePackA Blueprint

Inventory Menu On Start Play

Inventory Menu After Picking Up UpgradePackA

Any help is greatly appreciated! If I missed an AnswerHub post, please let me know! Thank you all!

I tried that method, but it gave the same results.

I had it setup so it would create an actor to add to the inventory, add it to the inventory, then remove the item from the game world.

Is there any particular reason you are using the Append node and not the Add or Add Unique nodes for arrays?

Okay well so that wont be the issue then, its just got me wondering since I tend to use Add myself with out problems.

Where is DestroySelf being called from? I couldnt see that in the clip. If youre trying to Destroy the Actor while referencing it you can get issues if its Pending Destroy. The log will show a warning and possibly an error for that.

As you can see you are setting the Owner to your Spawned Actor as Self, this is the one youre about to Destroy. The Owner should really be the Player Character in this case, not sure if that has anything to do with your problem though.

Im not sure if the issue is with the pieces of code you show or not, another idea might be to check the output of Spawn for validity as you may be adding null entries to the array. You could maybe fiddle with the Collision Handling Override, Im not sure if your Actor has anything that might collide causing it to not Spawn.

You should manually remove the item in the array before or after destroying it because your CurrentEquipment array still referenced an empty actor( destroyed upgradepack).

Fix would be.

BeginUsing_Event → castToPlayerCharacter → getCurrentEquipment → removeItem(self) ->Destroy.

The weapons on the map that are added on spawn are hidden outside of where the player may go, the upgrade pack added on Spawn was built into the level. Will try messing with Collision Handling Override

I am thinking that it may be something with the inventory menu, not the button or items. The first item added is 100% of the time correct and right, the others it all depends. That is no matter how I add it to the array. The menu creates children of a parent inventory button to get all of the items. Once it does that, the button then sees if it is at index 0 and sets itself to that, the others skip 0. This allows me to leave the parent button visible. This may be causing my issue.

Yeah you’ll just have to step through the code, try using break points and watch variables and plenty of print strings even if its just to the log. This should give you more of an indication of where the issue is occuring and really nail down that big of problematic code.

I do think kuruso has a point too about entries not being deleted correctly so thats something to watch out for.