I wrote a script to pickup objects on collision, and subtract from a var.
var stilltofind = 6;
var leveltoload : String;
function OnControllerColliderHit (hit : ControllerColliderHit) {
if(hit.gameObject.tag == "topickup"){
Destroy(hit.gameObject);
stilltofind -= 1;
}
}
function Update () {
if(stilltofind == 0){
Application.LoadLevel(leveltoload);
}
}
When I play the game, and go to the object, the object doesn’t disappear, and the var isn’t subtracted from.
Can somone troubleshoot?