void Update() { if (Input.GetKeyDown(KeyCode.P)) { IUnit prey; int numberOfPrey = 5; m_Preys = new IUnit[numberOfPrey]; for (int i = 0; i < numberOfPrey; i++) { prey = new Prey(); m_Grid.AddToRandomnPosition(prey); m_Preys[i] = prey; Debug.Log("A prey was spawned @ square: " + m_Preys[i].GetGridPosition()); } } if (Input.GetKeyDown(KeyCode.H)) { IUnit predator; predator = new Predator(); m_Grid.AddToRandomnPosition(predator); Debug.Log("A predator was spawned @ square: " + predator.GetGridPosition()); int closest = m_Grid.FindClosest(predator, m_Preys); Debug.Log("The closest prey is @ square: " + closest); } }