Object reference not set to an instance of an object in line 15 where theworld[j,k,i] = (byte)(0);:
using UnityEngine;
using System.Collections;
public class WORLD : MonoBehaviour {
byte[,,] theworld = new byte[1000,1000,1000];
public Transform rock;
void Start () {
for(int i = 0; i < 1000; i++)
{
for(int j = 0; j < 1000; j++)
{
for(int k = 0; k < 3; k++)
{
theworld[j,k,i] = (byte)(0);
}
}
}
Generate(Random.seed);
}
void Update () {
}
void Generate(int seed)
{
for(int i = 1; i < 1000; i++)
{
for(int j = 1; j < 1000; j++)
{
int height = Random.Range(1, 2);
for(int k = 1; k < height+1; k++)
{
theworld[j,k,i] = (byte)(1);
}
}
}
for(int i = 1; i < 1000; i++)
{
for(int j = 1; j < 1000; j++)
{
for(int k = 1; k < 3; k++)
{
if(theworld[j+1,k,i] == (byte)(0) ||
theworld[j,k,i+1] == (byte)(0) ||
theworld[j-1,k,i] == (byte)(0) ||
theworld[j,k,i-1] == (byte)(0) ||
theworld[j,k+1,i] == (byte)(0) ||
theworld[j,k-1,i] == (byte)(0)
)
{
Instantiate (rock, new Vector3(j,k,i), Quaternion.identity);
}
}
}
}
}
}