- Home /
Issues with semi-unique items in List becoming identical copies
I am roughly a month into learning C# and Unity, and so far I am pretty happy with my current project. I have made a very simplified action RPG (much like Diablo) that generates items, weapons and armor when an enemy is killed. This generated item is added to a List and then eventually added to my inventory once all enemies in the scene are dead. Some of these items may have the same base (i.e. leather gloves) but the added lines of stats are added to that item's own list and can be quite different from this leather glove and that leather glove.
So far this has worked very well, except for one occasion. When the same base item is dropped in the same scene twice. Not only do these items become copies of each other, but they also combine their lists of stats into one giant list of stats. I'm not sure how this is happening. I didn't know lists could even be combined without using certain functions? Any idea how this could be happening? After an item base is determined, the item is added to the list and I use an index to make certain that all manipulations to that item (i.e adding lines of stats) only affect one item. I'd post my code, but it's a bit lengthy and items consult another script to determine what stats appear on the item.