Hello everyone, can you guys help, I’m making a card game in unity and I’m having trouble in saving.
I’m suppose to sacrifice/delete 5 cards then save the left over cards in a list, every time I delete a card the index of the next card to be deleted goes down that part I get, Problem is that if I were to delete the 5 cards in a random order the index gets all mixed up.
Can anyone help/suggest with the deleting from the list part tried using removeat(index - 1) in a for loop but keeps returning an argument out of range exception.
Typically the pattern to do so is something like this:
for(int i=0;i<items.Count;i++)
{
if(ShouldRemove(items*))*
{
items.RemoveAt(i);
i–;
}
}
That way it always goes to the next item, whether you remove one in this iteration or not.