Search Unity

Match 3 game error: CS0029

Discussion in 'Scripting' started by melvinbutler, Jul 5, 2015.

  1. melvinbutler

    melvinbutler

    Joined:
    Jul 2, 2015
    Posts:
    9
    Hi, Do you happen to have any suggestion?

    I'm making a 2d match 3 style game and receive an error: CS0029 Line 19,17 Cannot implicitly convert type 'int[,]' to 'int[]'

    ********C#********
    using UnityEngine;
    using System.Collections;
    public class GridManager : MonoBehaviour
    {
    public int GridWidth;
    public int GridHeight;
    public int[] Grid;
    public GameObject[] TilePrefabs;

    void Awake ()
    {
    CreateGrid ();
    }
    void CreateGrid ()
    {
    Grid = new int[GridWidth, GridHeight];

    for (int x = 0; x < GridWidth; x++)
    {
    int randomTile = Random.Range (0, TilePrefabs.Length);
    Grid[x,y] = randomTile;
    Instantantiate (TilePrefabs[randomTile], new Vector2 (x,y), Quaternion.identity);
    }
    }
    }

    Thanks, Melvin
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Code (CSharp):
    1. public int [,] grid;