Answer the question
In order to leave comments, you need to log in
How to fill the playing field with numbers?
Good evening.
I'm making a game on Unity (I took the off-line roguelike tutorial as a basis).
You need to make a playing field filled with one texture (background) and random numbers on top of it.
I wrote a cycle (altered from the tutorial):
void BoardSetup()
{
boardHolder = new GameObject("Board").transform;
for (int x = 0; x < columns; x++)
{
for (int y = 0; y < rows; y++)
{
GameObject toInstantiateBackground = snowTile;
GameObject backgroundInstance = Instantiate(toInstantiateBackground, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
backgroundInstance.transform.SetParent(boardHolder);
GameObject toInstantiateDigit = digitTiles[Random.Range(0, digitTiles.Length)];
GameObject digitInstance = Instantiate(toInstantiateDigit, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
digitInstance.transform.SetParent(backgroundInstance.transform);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question