I keep getting this error and I don’t understand it:
NullReferenceException: Object reference not set to an instance of an object
SpawnScenery+$MakebigRock$31+$.MoveNext () (at Assets/SpawnScenery.js:18)
UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
SpawnScenery:Update() (at Assets/SpawnScenery.js:6)
It refers to this script that I have named SpawnScenery:
var bigRock: GameObject;
var big : boolean = true;
function Update () { if(big) { MakebigRock(); }}
//-------------------------------------------------------------------------------------------------------------------------------------//
//SCENERY
//-------------------------------------------------------------------------------------------------------------------------------------//
function MakebigRock()
{
//making sure we dont make too many big rocks
big = false;
// making the rocks
Instantiate( bigRock, Vector3 (Random.Range(-20.0, -10.0), 0, transform.position.z), transform.rotate);
Instantiate( bigRock, Vector3( Random.Range( 10.0, 20.0), 0, transform.position.z), transform.rotate);
// wait now
yield WaitForSeconds(Random.Range(50.0, 70.0)* Time.deltaTime);
// now create another
big = true;
}
I have no idea what to do. I don’t see a problem with the code. the object that I am spawning doesn’t have any problems … I don’t know what to do.
Please help