I was making a code to highlight the allowed moves for a chess game. Then when I tried to run it in unity I got this error: "IndexOutOfRangeException: Array index is out of range." Anyone know how to fix('if (moves[i, j]' is the line with the error) .
public void HighlightAllowedMoves(bool[,] moves)
{
for(int i = 0; i <= 8; i++)
{
for (int j = 0; j <= 8; j++)
{
if (moves[i, j])
{
GameObject go = GetHighlightObject();
go.SetActive(true);
go.transform.position = new Vector3(i + 0.5f, 0, j + 0.5f);
}
}
}
}
↧