How would I store lots of data in different scriptable object arrays

Hopefully this explanation isn’t too confusing. So, I was working on a magazine system where the player could open their inventory and see the magazines for all of their currently equipped guns. The player can change the order that the magazines are loaded into the guns. I currently got this working correctly where the players magazines are instantiated into their different slots. Then if you switch the weapon the magazines are stored in the weapon data scriptable object’s array in the order they were put in and the instances are destroyed. But then I realized that you can’t store gameobjects then delete their instance since that also deletes the one in the array. So, what would be the best way to go about the storing the multiple magazines and their data (ammo count, max capacity, ammo type, etc.) in a list inside of a scriptable object. Another thing I was thinking about was instantiating the magazines, referencing them, then setting them as inactive and activating them when the gun is equipped. But I feel like that might clutter the hierarchy if I had like 20 guns with 8 magazines each.

Is there a particular reason that magazines need to be GameObjects or ScriptableObjects at all? Why can’t they be regular classes?

2 Likes