My Script is:
void DestroyBlock ()
{
if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, range))
{
if (hit.collider.transform.parent.tag == "Block")
{
Destroy(hit.collider.transform.parent.gameObject);
Vector3 hitPos = hit.collider.transform.parent.transform.position;
int x = (int) hitPos.x;
int y = (int) hitPos.y;
int z = (int) hitPos.z;
Destroy(levelData[x, y, z].gameObject); *** this is where the error is
dataScript.levelData = levelData;
}
}
}
null reference exception: object reference not set to an instance of an object