I have a few enemies in my scene that I want to be active one at a time. As i destroy an enemy, the next one will become active. Here’s what I’m working with:
EnemyAI.cs
public static bool isActive = true;
void Update()
{
if(isActive == false)
{
GetComponent<EnemyAI>().enabled = false;
}
}
In the script above, I have the isActive bool set to true but I want the script to be disabled if it is set to false, here’s where my problem is:
EnemyBehaviour.cs
public int shipCount = 13;
void Start()
{
GameObject[] ships = new GameObject[shipCount];
for(int i = 1; i < shipCount; i++)
{
ships *= GameObject.FindWithTag ("ship" + i);*
_ foreach(GameObject ship in ships*)_
_ {_
_ EnemyAI.isActive = false;_
_ }_
_ }_
_ }_
I want to find all of my ships with the correct tags and set them to false (except for the first one, that’s why I start the loop at 1)
I used a for loop to find the objects and I wanted to then use a foreach loop to iterate through that list and set each ships (not including the first one) bool isActive to false but it throws me this error:
_[31406-capture.png*|31406]*
_*
I’m a bit stumped as to how to work around it so if anyone could help me out, I’d appreciate it