How do I get my weapons to save their ammo use when they are switched?

I have some code that allows the weapon to swap between the weapons they have using the Q input. I also have an ammo system in which every weapon has a set amount of ammo (sniper with 5, assault rifle with 30, etc) and when you run out you press space to reload.

However, putting them together has me a little confused as I am not sure how to get it so when you switch, it keeps the ammo you had on that weapon. At the moment, everything you switch, it resets to the default max.

The first two images are my ammo code and the latter is my switching weapons. Any help would be greatly appreciated!



I suggest to use Data Asset to for your weapon: https://youtu.be/Pb0uhYoUmb8?si=fHkDFiNXltuunydF

Or use of Structure that will store WeaponID, AmmoMax, AmmoCurrent.

Inside your bp character, store an array of that Structure such that each weapon will have their own properties.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.