I am trying to write a RPG-style inventory handler.
Each object that can be picked up by the player has a script attached to it which contains variables for the object information (name, weight, value, etc…). When an object is picked up, its information is recorded by the inventory handler script then the object is destroyed. When the player drops the object, a new copy is instantiated and the information recorded in the inventory is assigned to the new copy.
Now is where the problem occurs… The variables containing the object information in the script attached to the new object and the variables which represented the object in the inventory handler script are somehow linked. For example, if I alter the weight variable in the object script with the inspector, the corresponding weight variable in the inventory script is changed to the same value. Likewise, if I alter the one of the weights through the script, the other is also changed.
What can I do to not have the two linked like this?