I add items to a list to keep track of bullets, but I also need to delete the bullets from the game and the list at some point . Since I am using Destroy it makes things difficult.
I cant delete the bullets from the list.
I keep track of bullets like this
private List _bullets2 = new List();…
…
Rigidbody mybullet;
mybullet = Instantiate(projectile, transform.position, transform.rotation) as Rigidbody;
mybullet.AddForce(transform.forward * 1000);
Destroy(mybullet.gameObject,3);
_bullets2.Add(mybullet);
////////////////////////////
//to delete items from this list when unity destroys the object I iterate throigh the list backwards but get an error
‘_bullets2’ cannot be used as method or delegate
for(int i = _bullets2.Count - 1; i >= 0 ; i–)
{
if(_bullets2(i)==null)
_bullets2.Remove(_bullets2(i));