I have this code that counts how many GameObjects (crops) in the scene
GameObject[] crops;
and the code to get the health component of each crops
Health[] health;
crops = GameObject.FindGameObjectsWithTag("Crop");
health = new Health[crops.Length];
for (int i = 0; i < crops.Length; i++)
{
health[i] = crops[i].GetComponent<Health>();
}
I can now access the state of these crops using
health[i].Invulnerable //this is a bool from the Health.cs script
now I want to count the crops that are Vulnerable and Invulnerable. How can I achieve that? Thanks!