in my world generation and management script get this error…
the error:
NullReferenceException: Object reference not set to an instance of an object
World.PlaceBlock (Int32 x, Int32 y, Int32 BlockID) (at Assets/World/World.cs:95)
World+c__Iterator2.MoveNext () (at Assets/World/World.cs:84)
UnityEngine.MonoBehaviour:StartCoroutine(String)
World:Start() (at Assets/World/World.cs:27)
caused by this:
if(map[x,y].ItemTransform != null) // Line 93
{
Destroy(map[x,y].ItemTransform.gameObject);
}
this is everything to do with the ‘map’ variable
public class Map
{
public Transform ItemTransform;
public int ID;
public Map(Transform ObjectTransform, int objectID)
{
ObjectTransform = ItemTransform;
ID = objectID;
}
}
public Map[,] map = new Map[30, 10];
[15112-script.zip|15112]
help would much appreciated, thank you