- Home /
Question by
SunilPandey__ · Sep 26, 2013 at 07:14 AM ·
list
Removing elements of list
I have created a list
enemies = new List ();
and adding elements in it like
enemies.Add ((GameObject)Instantiate (enemyPrefab, new Vector3 (transform.position.x * (i), transform.position.y, transform.position.z), Quaternion.identity));
count++;
now when i want to remove elements from enemies list as
if(count>0 && (Time.time)>15){
enemies.RemoveAt(0);
}
then element is not removed from list.. why?
please format your code properly in future - AlucardJay
Comment
That should remove the enemy from the list, but not remove it from the game - are you sure it's still in the list?
That code looks fine to me. What makes you believe that the element has not been removed?
@hoeloe and tanoshimi: thanks for reply. you are right it removes elements from list. but not from game. how to do it.