public void MoveTowardsBall(GameObject ball, float speed) { if (listOfAI.Count == 0) { ZLog.Print("There are no enemies left!"); } else { foreach (GameObject ai in ServicesLocator.AIManager.listOfAI) { if (ai.GetComponent <RefereeController>()) { continue; } else if (ai.GetComponent <AIController>()) { ai.GetComponent <AIController>().MoveTowardsBall(ball, speed); } } } }