Download

Adding Ammo in an Inventory System

I made a normal tile based Inventory system that has the ability to use the consumable, splitting stacked items etc. I wanted to add the ammo system but I can’t seem to figure out how to do this. My Fire function is actually in the guns. So I need help with this

This is the Function I came up with. So it searches the Slots to find the Ammo class and notes the Index and Amount it had.

And I created a function Where When the gun is called on, it updates itself with the info at the inventory and when I call the gun (pressing 2) I attach this function to the Key pressed function.

But the problem is None of this is working as intended. I can’t really figure it out