private void InstantiatePieces(List <int> activePieces) { // Instantiate pieces, set parent if (activePieces.Count > 0) { var leftPiece = Instantiate(pieces.GetPieceAt(activePieces[0])); leftPiece.transform.parent = leftSpawnPoint; leftPiece.GetComponent <Piece>().SetInitialPositionAndKey(leftSpawnPoint.transform.position, activePieces[0]); } if (activePieces.Count > 1) { var centerPiece = Instantiate(pieces.GetPieceAt(activePieces[1])); centerPiece.transform.parent = centerSpawnPoint; centerPiece.GetComponent <Piece>().SetInitialPositionAndKey(centerSpawnPoint.transform.position, activePieces[1]); } if (activePieces.Count > 2) { var rightPiece = Instantiate(pieces.GetPieceAt(activePieces[2])); rightPiece.transform.parent = rightSpawnPoint; rightPiece.GetComponent <Piece>().SetInitialPositionAndKey(rightSpawnPoint.transform.position, activePieces[2]); } }