Hello, im try destroy some objects who have created and put in a List, are clones, this is the code:
(method Start)..
StartCoroutine ("Spaw");
}
IEnumerator Spaw(){
if(list == null) list = new List<Rigidbody2D>();
float waittime = Random.Range (minTimeBetweenSpawns, maxTimeBetweenSpawns);
yield return new WaitForSeconds (waittime);
float posY = Random.Range(minSpawnPosY, maxSpawnPosY);
float posX = Random.Range (-11,11);
Vector3 spawnPos = new Vector3(posX,posY, transform.position.z);
Rigidbody2D propInstance = Instantiate (plataforma, spawnPos, Quaternion.identity) as Rigidbody2D;
list.Add (propInstance);
StartCoroutine (Spaw());
if (list.Count >= 3) {
Debug.Log("A conta e de "+list.Count);
foreach(Rigidbody2D rigid in list){
**Destroy(rigid);**
}
list = null;
list = new List<Rigidbody2D>();
}
}
the basic is the Destroy(rigid) and the DestroyImmediate method i try put also, but in the Game dont remove anithing, please, what i make wrong ? Thanks much.