Hi,
i have a “unit” class which has a Vector3-List attribute named “currPath”. I have a List of “units” and i want to remove the first element of the “currPath” attribute of every “unit” individualy(so i can only delete them under certain conditions). my problem is that everytime i call the RemoveAt(0)-Metod of the list it deletes the first element of every “unit” at once. so if i loop through every “unit” id deletet as many items from the “currPath” list as “units” i iterated through.
For example:
i start with:
Unit 1: currPath = [1,2,3,4]
Unit 2: currPath = [1,2,3,4]
and the code is something like
foreach (unit in units){
unit.currPath.RemoveAt(0)
}
my return is:
Unit 1: currPath = [3,4]
Unit 2: currPath = [3,4]
and not:
Unit 1: currPath = [2,3,4]
Unit 2: currPath = [2,3,4]
i dont refference currPath anywhere else.
Thanks for any help.