Type Object does not support slicing Unity3D
Posted
by
Vish
on Game Development
See other posts from Game Development
or by Vish
Published on 2012-06-03T13:58:05Z
Indexed on
2012/06/03
16:48 UTC
Read the original article
Hit count: 898
unity
I am getting the following error in my code and I can't seem to understand why. Can anyone help me with it?
This is my current code. The line causing the error is marked in a comment near the end.
var rows : int = 4;
var cols : int = 4;
var totalCards : int = cols * rows;
var matchesNeedToWin : int = totalCards * 0.5;
var matchesMade : int = 0;
var cardW : int = 100;
var cardH : int = 100;
var aCards : Array;
var aGrid : Array;
// This Array will store the two cards that the player flipped
var aCardsFlipped : ArrayList;
// To prevent player from clicking buttons when we don't want him to
var playerCanClick : boolean;
var playerHasWon : boolean = false;
class Card extends System.Object {
var isFaceUp : boolean = false;
var isMatched : boolean = false;
var img : String;
function Card () {
img = "robot";
}
}
function Start () {
var i : int = 0;
var j : int = 0;
playerCanClick = true;
aCards = new Array ();
aGrid = new Array ();
aCardsFlipped = new ArrayList ();
for ( i = 0; i < rows; i++) {
aGrid [i] = new Array ();
for (j = 0; j < cols; cols++ ) {
aGrid [i] [j] = new Card (); // <------ Error over here
}
}
}
function Update () {
Debug.Log("Game Screen has loaded");
}
The error states as follows:
Error BCE0048: Type 'Object' does not support slicing. (BCE0048) (Assembly-UnityScript)
© Game Development or respective owner