Hi, I’ve been trying to instantiate an object in a certain position (for example at the center but retaining the spaces in between each cell) I’m new in unity and I’m having a hard time manipulating the code. Thankyou for for help.
using UnityEngine;
using System.Collections;
public class GridGenerator : MonoBehaviour {
public int width;
public int height;
public Transform BoardGenerator;
public Transform cell;
// Use this for initialization
void Start () {
GenerateGrid();
}
void GenerateGrid() {
for (int x = 0; x < height; x++) {
for (int y = 0; y < width; y++) {
BoardGenerator = Instantiate (cell.gameObject).transform;
BoardGenerator.parent = transform;
BoardGenerator.position = new Vector3(88 * x, 88 * y, 0);
}
}
}
}