Hello all.
I am making an inventory system and trying to remove items with known indexes (from UI of the inventory window when player drops/uses items) stored in an array. I made an TArray made of FInventoryItem class simply called Inventory. To just test it I tried removing first item from the inventory at index 0 by
if (Inventory.IsValidIndex(0))
{
Inventory.RemoveAt(0, 1, false);
UpdateInventory(); // This is just updating the UI, it is descrebed below this function
}
but the thing is it is removing the first item and then shifting the second item in it’s place.
What exactly am I getting wrong here ? I checked around a bit but not sure how to approach this.
Also some tutorials I have seen suggested “making a copy of the array you are working with, working on it and then simply copy it to your real array to prevent crashes and index errors”. Is this a thing ?
Thanks and respects.