Hi,i made a list where i store some gameobjects. The gameobjects in the list are sorted by the distance from the player (if i’m not clear i mean element 0: nearest object to player,element 1:2nd nearest object to player etc.)When the player reaches the element 0 of the list this element is removed from the list and stored in another “trash” list.
The problem is when i add the item in the trash list,it adds the element at every frame and it should add it once.
public List listMete = new List(); //list that stores gameobject to reach
public List listMeteTrash = new List()//trash list,stores reached gameobjects
void Update()
{
if (transform.position == listMete[0].transform.position)
{
for(int i=0;i<1;i++)
{
listMeteTrash.Add(listMete[0]);
listMete.Remove(listMete[0]); //here works correctly
}
}
}
Thanks in advance guys!