So I am making an inventory system and am trying to make it so that half of the stack is picked up when right clicked. However when i copy the item in the slot to the floating item they act like they are the same variable so when I change the stack count to changes on both.
eg it I subtract 1 from the other the other also has 1 subtracted.
int giveNumber = (item.stackCount + 1) / 2;
parentInventory.floatingItem = item;
item.stackCount -= giveNumber;
parentInventory.floatingItem.stackCount = giveNumber;
if(item.stackCount < 1)
{
item = new Item();
}
could someone please help me as I don’t know why the values are attached.