- Home /
Question by
Alexander42 · Apr 29, 2016 at 05:41 AM ·
instantiateprefabgridunassigned
Trying to create grid, "Use of unassigned local variable" error for prefab of tile although it is assigned?
public class GridCreator : MonoBehaviour
{
public int x = 4;
public int y= 4;
// Use this for initialization
void Start()
{
for (int Horizontal = 0; Horizontal < x; Horizontal++)
{
for (int Vertical = 0; Vertical < y; Vertical++)
{
GameObject GridObject;
Vector3 grid_setup = new Vector3(Horizontal, Vertical, 0);
Instantiate(GridObject, grid_setup, Quaternion.identity);
}
}
}
}
The first variable for Instantiate, the Object, is where it starts complainging. Also tried defining it using Rigidbody, still had same error. Trying to change Instantiate to GridObject.Instantiate causes the whole thing to flip out.
Comment