Inventory system array issues

This is the normal behavior of an array, you’ll need to use another method if you want to accomplish such a thing.
I agree with Rev0verDrive, you could simply use three variables.

If you want to use something that can easily be expended, like an Array, I’d recommand using a Map with number as Key and your Item as Value.
Here’s an example, I’m using an Actor as a value instead of you item.
help 1

I can add actor to this Map easilly. Here I’ll just spawn some actors in my level as a example to add things to my Map. And I’ll set each actor to a specific number.

And I’ll add a keyboard event to remove the first actor in my map.
help 3

I’ll also add a small PrintMap function to print if the Key 0 or 1 has a value. I’ll call it at the Begin Play and after pressing L.

And here’s my Output Log. When I spawn, I have an actor on Key 0 and Key 1. Right after that I press L.
And see, I no longer have an actor attached to the Key 0, and the one attached to Key 1 hasn’t moved.
help

Hope it’ll help :grinning: !

2 Likes