private void SpawnUnit(Unit unit) { unit.transform.parent = GameObject.Find("Units Parent").transform; List <Cell> cells = new List <Cell>(); Cell cell = null; for (int i = 0; i < cellGrid.Cells.Count; i++) { if (cellGrid.Cells[i].transform.position.x == this.transform.position.x && cellGrid.Cells[i].transform.position.y == this.transform.position.y) { cell = cellGrid.Cells[i]; break; } } if (cell != null) { cellGrid.GetComponent <CustomUnitGenerator>().SpawnUnit(unit, cell); cellGrid.GetComponent <CustomUnitGenerator>().SnapToGrid(); unit.MovementPoints = 0; } }