Intro:
A car runs over a Pizza. It shall disappear, and ++ PizzaAmount
When PizzaAmount is greater than 0, you can click on Jump = P, and spawn a Pizza
There is no problem by make the Pizza Disapear, when you run over.
When i want to drop the pizza, this code is in used
function Update () {
if(Input.GetButtonDown("Jump"))
{
MorePizza();
}
}
function MorePizza (){
if(PizzaAmount>0){
var pizza = Instantiate(PizzaPrefab, GameObject.Find("carSpawn").transform.position, Quaternion.identity);
PizzaAmount --;
yield WaitForSeconds(1)
}
}
But when as soon PizzaAmount is greater than 1, and i press Jump, it gives me this error
NullReferenceException
PizzaHit+$MorePizza$30+$.MoveNext () (at Assets/Scripts/PizzaHit.js:16)
UnityEngine.MonoBehaviour:StartCoroutine_Auto(IEnumerator)
PizzaHit:Update() (at Assets/Scripts/PizzaHit.js:10)
I am hoping you could help me, and I am hoping that i am clearing it out right