What does it mean my object reference isnt set to an instance of an object? The array is a public static variable in another class called BlockData. The error refers to the “foreach” loop line of code.
private void updateChunks() {
foreach(Transform curChunk in BlockData.currentChunk) {
if(Vector3.Distance(player.position,curChunk.position) < 20) {
chunksToRender.Add(curChunk);
}
}
renderBlock();
}
rather of all BlockData.currentChunk is null, check it before foreach block using
Debug.Log(BlockData.currentChunk);
to be sure. the fix if it so.