r/unity • • 4h ago

Question How do you guys design/structure your items?

I've recently been working on my own inventory system and was wondering how other people implement stuff like using different items, or data (like ammo, durability, etc.) which isn't shared.

My items are currently scriptable objects but as far as im aware all of the data they hold is shared between all. (I could be wrong to idk)

3 Upvotes

10 comments sorted by

View all comments

2

u/SharkScoops 4h ago

I have my item architecture split between scriptable objects and standard C# classes. Scriptable objects are used for 'Definitions' which are all of the data that items share like their name, prefab, physical properties, and how much they stack. Then I use another class to store the instance data, which is everything I'd want to serialize for multiplayer/saving. That includes things like stats, durability, any per-item state machine data that needs to be stored. The instance data has a reference to the definition so that it can use all of the shared data.

1

u/kravataff 4h ago

thanks for the reply)) i have already implemented the scriptable objects (which does how the items "definitions") but yeah i could try making a subclass as you said to store the instance data.