Ok I have enemyManger which instantiate a prefab that has a movement script attached to it . I created a tag so i can collect them later . now I do want to have a freeze bomb which disable their movement for a while but it seems not to work
IEnumerator Enemyfreezer()
{
yield return new WaitForSeconds(1f);
GameObject[] gameObjectArray = GameObject.FindGameObjectsWithTag("Zombie");
foreach (GameObject go in gameObjectArray)
{
go.GetComponent<EnemyMovement>().enabled = false;
}
yield return new WaitForSeconds(3f);
GameObject[] gameObjectArray1 = GameObject.FindGameObjectsWithTag("Zombie");
foreach (GameObject go in gameObjectArray1)
{
go.GetComponent<EnemyMovement>().enabled = true;
}
}
But when I replace the EnemyMovement with other component rather than a scripts it works just fine . like Animator component :
IEnumerator Enemyfreezer()
{
yield return new WaitForSeconds(1f);
GameObject[] gameObjectArray = GameObject.FindGameObjectsWithTag("Zombie");
foreach (GameObject go in gameObjectArray)
{
go.GetComponent<Animator>().enabled = false;
}
yield return new WaitForSeconds(3f);
GameObject[] gameObjectArray1 = GameObject.FindGameObjectsWithTag("Zombie");
foreach (GameObject go in gameObjectArray1)
{
go.GetComponent<Animator>().enabled = true;
}
}
Help Please