"instance" unexpected symbol?
Hey I decided to pick up Unity again and I'm following this tutorial for a 2D Rogue Like (link below) and I have run into a problem. https://unity3d.com/learn/tutorials/projects/2d-roguelike-tutorial/writing-board-manager?playlist=17150
For whatever reason, the line "instance.transform.SetParent (boardHolder); is not working. the messsage I get in the console is this exactly. "Assets/scripts/boardmanager.cs(67 ,4): error CS1525; Unexpected symbol 'instance' "
here is the code I wrote as the tutorial said to write.
void BoardSetup () { boardHolder = new GameObject ("Board").transform;
for(int x = -1; x < columns + 1; x++)
{
for(int y = -1; y < rows + 1; y++)
{
GameObject toInstantiate = floorTiles[Random.Range (0, floorTiles.Length)];
if(x == -1 || x == columns || y == -1 || y == rows)
toInstantiate = outerWallTiles [Random.Range (0, outerWallTiles.Length)];
GameObject instance =
Instantiate (toInstantiate, new Vector3 (x, y, 0f), Quaternion.identity) as GameObject
instance.transform.SetParent (boardHolder);
}
}
}
Any sort of help would be great appreciated!
Answer by Matthewj866 · May 22, 2017 at 07:28 PM
Instantiate (toInstantiate, new Vector3 (x, y, 0f), Quaternion.identity) as GameObject
needs a semicolon.
It is saying unexpected symbol because you never finished the previous line with said semicolon and as a result it thinks it's one line, and of course those two lines together as one don't make any sense to the compiler.
Your answer
