I can not identify my prefabs with the tags that I have defined, I have already added the tags to the prefixes as you can see below:
Andmystatus:
publicvoidChecks(){for(inty=0;y<gridHeight;++y){for(intx=0;x<gridWidth;++x){if(Grid[x,y]!=null){if(Grid[x,y].tag=="CARBONO") {
Debug.Log ("EXISTE C: ");
if (Grid [x + 1, y].tag == "HIDROGENIO") {
cont++;
}
if (Grid [x - 1, y].tag == "HIDROGENIO") {
cont++;
}
if (Grid [x, y + 1].tag == "HIDROGENIO") {
cont++;
}
if (Grid [x, y - 1].tag == "HIDROGENIO") {
cont++;
}
}
Debug.Log ("contador: " + cont); //teste
}
}
}
}
I put a checker to see if it goes into the condition that there is a C in my grid, but as long as my grid appears prefab C it goes straight through and does not do the rest of the checks.
The function that generates my prefabs randomly:
string GetRandomTetromino(){
int randomTetromino = Random.Range (1, 5);
string randomTetrominoName = "Prefabs/C";
switch (randomTetromino) {
case 1:
randomTetrominoName = "Prefabs/H";
break;
case 2:
randomTetrominoName = "Prefabs/C";
break;
case 3:
randomTetrominoName = "Prefabs/H";
break;
case 4:
randomTetrominoName = "Prefabs/C";
break;
}
return randomTetrominoName;
}
and the function that plays the prefab generated in the coordinates ta dela:
public void SpawnNextTetromino () {
if (!gameStarted) {
gameStarted = true;
nextTetromino = (GameObject)Instantiate(Resources.Load(GetRandomTetromino(), typeof(GameObject)), new Vector2 (5.0f, 22.0f), Quaternion.identity);
previewTetromino = (GameObject)Instantiate (Resources.Load (GetRandomTetromino (), typeof(GameObject)), previewTetrominoPosition, Quaternion.identity);
previewTetromino.GetComponent<Tetromino> ().enabled = false;
} else {
previewTetromino.transform.localPosition = new Vector2 (5.0f, 20.0f);
nextTetromino = previewTetromino;
nextTetromino.GetComponent<Tetromino> ().enabled = true;
previewTetromino = (GameObject)Instantiate (Resources.Load (GetRandomTetromino (), typeof(GameObject)), previewTetrominoPosition, Quaternion.identity);
previewTetromino.GetComponent<Tetromino> ().enabled = false;
}
}
Here is the repository for my game: link