Find border of Matrix (east, west, north, south)
I have a problem which, though easy I can not fix. In my scene I have a matrix that varies depending on the player's choice. Each box has to see if beside if there are neighboring boxes (east, west, north, south). I'm trying to find the limit of the east matrix. To do this, check whether each box (int) by dividing by the line in which is located as a result from the width of the array. But bad runs. You know you help me?
![void controll()
{
int random = 18;//Random.Range(0, cells.Length - 1);
int currentRow = ((random+1) / xSize)+1;
Renderer rnd;
rnd = cells[random].floor.GetComponent<Renderer>();
rnd.material.color = Color.red;
int eastLimited = (random / (currentRow ));
if (eastLimited != xSize-1) // est
{
Debug.Log("There are boxes to east");
}
else
{
Debug.Log("you're at the matrix");
}
}
][1]
[1]: /storage/temp/67161-matrix.png
matrix.png
(14.5 kB)
Comment