This is a very simple question, but I am new to Unity and JavaScript so I don't know how to do this. In my game, you can pick up items hidden in the levels that will unlock a bonus level when all 10 per level are collected - kind of like the Minikits or Artifacts in the LEGO games Travelers Tales has been making the past few years. I have made the following script:
var collectibles;
function OnTriggerEnter (object : Collider)
{
collectibles++;
Destroy (gameObject);
}
However, when I walk through the collectible, nothing happens. Unity then gives this error at the bottom of the screen:
NullReferenceException: Object reference not set to an instance of an object Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs) pickUpCollectible.OnTriggerEnter (UnityEngine.Collider object) (at Assets\Scripts\pickUpCollectible.js:4)
It says the error is on line 4. What am I doing wrong? I know this may sound stupid, but I can't figure it out. Thanks for the help! :)