Can anyone explain for me why we have to do this function. I read the instruction but I can’t figure out why.
Site : noobtuts - Unity 2D Tetris Tutorial
bool isValidGridPos() {
foreach (Transform child in transform) {
Vector2 v = Grid.roundVec2(child.position);
// Not inside Border?
if (!Grid.insideBorder(v))
return false;
// Block in grid cell (and not part of same group)?
if (Grid.grid[(int)v.x, (int)v.y] != null &&
Grid.grid[(int)v.x, (int)v.y].parent != transform)
return false;
}
return true;
}