// Update is called once per frame void Update() { for (int i = 0; i < WIDTH; ++i) { if (map[i, HEIGHT - 1] == null) { map[i, HEIGHT - 1] = Instantiate(prefab, new Vector3(i, 0, 0), Quaternion.identity) as GameObject; Candy candy = map[i, HEIGHT - 1].GetComponent <Candy>(); ECandyType type = GenerateCandyType(); candy.SetType(type); } } for (int i = 0; i < HEIGHT; ++i) { for (int j = 0; j < WIDTH; ++j) { if (map[j, i] == null) { map[j, i] = map[j, i + 1]; map[j, i + 1] = null; if (map[j, i] != null) { map[j, i].transform.position = new Vector3(j, i, 0); } } } } }