Compiler Errors :[

Following a simple tutorial. Followed the directions and coding to a tee, but I’m still getting errors:

Assets/Scripts/GameManager.cs(30,115): error CS1525: Unexpected symbol ;', expecting )‘, or `,’

Assets/Tile.cs(4,14): error CS0101: The namespace global::' already contains a definition for Tile’

Scripts:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GameManager : MonoBehaviour {

	public GameObject TilePrefab;

	public int mapSize = 12;

	List <List<Tile>> map = new List<List<Tile>>();


	// Use this for initialization
	void Start () {
		generateMap ();

	}

	// Update is called once per frame
	void Update () {

	}

	void generateMap() {
		map = new List<List<Tile>> ();
		for (int i = 0; i < mapSize; i++) {
			List <Tile> row = new List<Tile> ();
			for (int j = 0; j < mapSize; j++) {
				Tile tile = ((GameObject)Instantiate (TilePrefab, new Vector3 (i - Mathf.Floor (mapSize / 2), 0, -j + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<Tile> ())
				tile.gridPosition = new Vector2(i, j); 
				row.Add (tile);
					}
					map.Add (row);
					}
	}
}

and

using UnityEngine;
using System.Collections;

public class Tile : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

Keep getting compiling errors when following even the simplest scripting tutorials that seem to work for other people.

The error is telling you that there is a problem in line 30 which contains this:

Tile tile = ((GameObject) Instantiate (TilePrefab, new Vector3 (i - Mathf.Floor (mapSize / 2), 0, -j + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<Tile> ())

If you replace the last closing parentheses with a semicolon then the problem goes away. Like so:

Tile tile = ((GameObject) Instantiate (TilePrefab, new Vector3 (i - Mathf.Floor (mapSize / 2), 0, -j + Mathf.Floor (mapSize / 2)), Quaternion.Euler (new Vector3 ()))).GetComponent<Tile>();

After this you will get an error for line 31 because your Tile class doesn’t have the “gridPosition” variable yet. Fix that and your script should run without errors.