I'm trying to get a 2d tilemap rendering but somethings not clicking with me about the 2d coordinates...
Here's my basic tilemap class -
public class Map : MonoBehaviour {
public Transform tilePrefab;
public int mapWidth;
public int mapHeight;
public Transform[,] map;
// Use this for initialization
void Start () {
map = new Transform[mapWidth, mapHeight];
for (int y = 0; y < mapHeight; y++)
{
for (int x = 0; x < mapWidth; x++)
{
Transform tile = Instantiate(tilePrefab, new Vector3 (x, y, 0), Quaternion.identity) as Transform;
tile.parent = transform;
map[x, y] = tile;
}
}
}
But this is rendering the tilemap from the origin -
I want that tilemap to be dynamically centered on the camera like -
What I can't seem to work out is how to dynamically work out the coordinates to move that tilemap so that it's centered in the camera after it has been created.?
Any additional help /, or pointers to some decent resources would be much appreciated, cheers.