- Home /
Question by
scayetanot · May 14, 2016 at 05:22 PM ·
positiongridgrid based game
2D Board game grid placement
Hi,
I have followed the training to start build an app as a board game.
I have been able to have a grid, place obect but the placement is good in terms of location but the size of a cell is too small and object which are supposed to be in (1,1) (1,2) are not supposed to overlap.
void InitialiseList(){ gridPositions.Clear ();
for (int x = 1; x < columns; x++) {
for (int y = 1; y < rows ; y++) {
gridPositions.Add (new Vector3 (x, y, 0f));
}
}
}
void BoardSetup(){
boardHolder = new GameObject ("Board").transform;
}
void LayoutPlanetPlace(GameObject[] tileArray){
GameObject tileChoice = tileArray[Random.Range(0, tileArray.Length)];
Instantiate (tileChoice, new Vector3(2, 2, 0f), Quaternion.identity);
tileChoice = tileArray[Random.Range(0, tileArray.Length)];
Instantiate (tileChoice, new Vector3(3, 4, 0f), Quaternion.identity);
tileChoice = tileArray[Random.Range(0, tileArray.Length)];
Instantiate (tileChoice, new Vector3(1, 5, 0f), Quaternion.identity);
}
public void SetupScene(int level){
BoardSetup ();
InitialiseList ();
LayoutPlanetPlace (planetTile);
//Exit
Instantiate (station1Tile, new Vector3(columns-1, rows-1, 0f),Quaternion.identity);
}
}
Check the result
screen-shot-2016-05-14-at-101641.png
(22.2 kB)
Comment
Your answer
Follow this Question
Related Questions
Transform angle to grid position 2 Answers
Grid snapping 0 Answers
How to create a rotating tiles with walls on edges of tiles? 0 Answers
I need help to save my grid and show it in a different scene 2 Answers