void InstantiateMap() {
for (int x = 0; x < map.mapSizeX; x++) {
for (int y = 0; y < map.mapSizeY; y++) {
Debug.Log("Tile instantiated with pos: " + x + ", " + y);
Transform newTile = Instantiate(map.tiles[x, y].gameObject, new Vector3(x, 0, y), Quaternion.Euler(Vector3.right * 90)) as Transform;
newTile.parent = transform;
}
}
}
When I run my program I get an error with the line that sets the parent of the newTile.
Object reference not set to an instance of an object.
This script is attached to an empty game object in my scene.
I’ve also tried creating a new Transform to set it to but I get the same error even though I can clearly
see in the inspector that the transform is being created correctly.