Noob need help !

I want to reduce the array size if the gameObject in this array = null. I don’t know how to do that please help. Thank a lot !
public string chaseTag;
public GameObject[ ] ListTargets;
public GameObject[ ] Targets;

void Start () {
StartCoroutine (delay ());
}

// Update is called once per frame
IEnumerator delay () {
yield return new WaitForSeconds (0.5f);
if (ListTargets.Length<10) {
ListTargets = GameObject.FindGameObjectsWithTag(“Enemy”);
}
foreach (GameObject go in ListTargets) {
if (go == null) {
//reduce the ListTargets size or make this slot of this gameobject in an array disappear !
}
}
StartCoroutine (delay ());
}

First…

USE CODE TAGS!

Like so:

public string chaseTag;
public GameObject[] ListTargets;
public GameObject[] Targets;


void Start () {
    StartCoroutine (delay ());
}

// Update is called once per frame
IEnumerator delay () {
    yield return new WaitForSeconds (0.5f);
    if (ListTargets.Length<10) {
        ListTargets = GameObject.FindGameObjectsWithTag("Enemy");
    }
    foreach (GameObject go in ListTargets)
    {
        if (go == null)
        {
        //reduce the ListTargets size or make this slot of this gameobject in an array disappear !
        }
    }
    StartCoroutine (delay ());
}

Next… arrays don’t resize, so reducing the ListTargets size is not possible without creating a new array. You should use List if you want to be able to resize.

Furthermore… you just got that list by calling GameObject.FindGameObjectsWithTag(“Enemy”)… it should not have null entries.

Also, why start a whole new coroutine? Why not instead wrap this in a while(true) loop and just repeatedly run the same code?

thank you ! I already solve my problem