Link GameObject via foreach

I want to link my object “_enemy” with the list of objects"_basic" using foreach method. So, any object i add in the “_basic” elements should do the same what “_enemy” do.

public ie2 _enemy;
public GameObject[] _basic;

// Use this for initialization
void Start () {
	foreach (GameObject dd in _basic)
	{
		dd = _enemy;
	}
}

What are you trying to do here? With the current loop you will just be remapping the reference that “dd” points to so that it instead references “_enemy”. Anything that was previously in “dd” will no longer be referenced and you won’t be able to access it.

If your goal is to make “dd” move at the same time as _enemy you could make it a child of _enemy by using dd.transform.setParent(_enemy.transform)

I have a problem when duplicate my enemy and if i do this" public ie2 _enemy;" it give me error.
“public ie2 _enemy;” will have the main enemy, and “public GameObject _basic;” will have all duplicates enemies. they will do that same thing main enemy do.
No need to make a child because the function “setactive” that enemy have.