Problem with Items equipped, Enum

Hi guys and gals, I’m in need of your help once again. This time I made a short video illustrating the problem because it’s difficult for me to explain when typing.

This is the UI_Equipment widget script to update the slots:

can you please show the graphs for “set equipment slot” function/graph? I suspect problem may be there

I think I see the problem:
You are doing a foreach loop on the equipment array. I am not sure what you keep in that array (items you already equipped would be my guess) but whatever you are doing it gets done on ALL the objects in that array.

My guess as to what is happening: it starts with rifle: because rifle is already equipped it puts it into the secondary slot with 99 amount. Then it puts the grenades into their respective slot.

In effect you are putting all equipped items into the UI ONE MORE TIME. If you want to go this way I would recommend clearing the UI first (remove all equipped items from UI and reset the variables) and your function will add them all again.

The right solution would be different though. Keep the reference to the newly added item, and pass only that item into this function. This way it will be run only 1 time and will add the item into a free slot, without going through all equipped items.

EDIT: Quick fix: instead of iterating over the equipment array, add an input to your createEquipment custom event and pass in an array containing only the one new item you are adding to the inventory. Subsequently do your foreach on this custom event parameter array instead of your existing whole inventory array)

I believe your solution is the way to go and I’m excited about it. I’ll give it a try, I’ll let you know the result.

good luck! please accept the answer if it helped

Hey man, I cannot thank you enough! Now it works.

One more question, do you have any idea why my buttons are just white when it’s empty? probably it’s very easy, I’ll try to figure it out myself