Hello all, first off I’m just learning Unity so I’m probably doing something dumb, but: this code was working before, now I have to comment out the lines below to still instantiate correctly (which is place 4 rows of cards, each 12 cards high ), otherwise it only puts one card down instead of 48.
** When the commented sections below wasn’t throwing an error, all that was done was removed the ‘clcne’ in hierarchy and tacked on a name (no big deal), but the If statement was only allowing the first row of cards to be clicked on (disabled script in all other instantiated cards) which is core functionality.
#pragma strict
var cardCounter = 0;
function CreateLeftLane (lanename) {
var i : int = 0;
var pos = .2;
var cardNumber = 1; // assigning numbers, 1-12+ going up row
for (i = 0; i < laneLength; i++)
{
//pick a random item in array
var randNum = Random.Range (0, (prefabArray.Length));
var randCard = prefabArray[randNum];
Debug.Log ("Rolled a " + randNum);
Debug.Log ("Card is " + randCard);
var camerapos = Vector3(.34, 1.58, 0);
var cardstartpos = Vector3(pos,.8,.4);
if (lanename == "one")
{
cardstartpos = Vector3(pos,.8,.4); //place lane 1
var cardLane = "LaneA-";
}
else if (lanename == "two")
{
cardstartpos = Vector3(pos,.8,.15); //place lane 2
cardLane = "LaneB-";
}
else if (lanename == "three")
{
cardstartpos = Vector3(pos,.8,-.15); //place lane 3
cardLane = "LaneC-";
}
else if (lanename == "four")
{
cardstartpos = Vector3(pos,.8,-.4); //place lane 4
cardLane = "LaneD-";
}
//var newCard : Transform;
var newCard = Instantiate(randCard, cardstartpos, Quaternion.AngleAxis(270, Vector3.up));
// newCard.name = newCard.name.Replace("(Clone)","").Trim(); // take "Clone" off
// newCard.name = newCard.name + " " + cardLane + cardNumber; // add a number to it
// if (cardNumber != 1) { //only card on first row clickable
// newCard.GetComponent(FliponClick).enabled = false;
// }
cardNumber++;
pos += .2;
cardCounter++; // track # of cards
}
}