For each item in my game i have universal variables that are the same for evry instance saved in a prefabGameobject (might replace this with a json later) ,for example a bronze sword might always have a base attack strengh of 4 however i also have more variables that are item specific, for example the damage its endured, and i need to save this information in my inventory whenever its there
I have 2 main ideas but am open to any suggestions, there may well be a better way than both
1 i could have arrays that store a specific variable for each slot and i copy the data to the relevant index (slot number) in the array to store it , ef if item1 has a String X = turkey; and int Y = 3 ; and item 2 has a string X = sand ; and int Y = 5; then if each array is 4 long and starts with them all empty if i copy item 1 to index 1 and item 2 to index 2 then now String X = turkey , sand , empty , empty and int Y = 3,5,empty,empty , the information can hence be called by getting the value of evry array at the index of the slot you need
2 alternatively i could have an array of gameobjects and each item in the inventory could have a hidden gameobject containing the variables, this could just be the same gameobject that was previously on the ground before it was ‘picked up’ that has now been disabled to stop its usual behaviours of making particles and floating up and down and to stop it showing up in the world, by dissabling the collider it would also no longer be picked up by the itemsToPickup gameobject list in my pickupItem script
Im guessing the latter would be better since it isnt destroying any gameobjects and the data for any variable will still be stored even if i add new variables in the item - id dont need a new array to store any new variables
id appreciate any advice or suggestions
i hope it made sense if not just tell me