I have a script which is meant to destroy an object upon impact(that part works) and subtract from an integer(var /:int=n), but it only seems to subtract once. It should subtract whenever a collision with an object not named “Start” occurs, at least in theory.
I haven’t been able to find any way to fix it, though I’ve searched online for… well, over three days.
I’ve seem somebody with a problem of it refilling back to the original value, I think, but that does not seem to be the problem.
var targRMG:int=10;
function OnTriggerEnter(other:Collider){
yield WaitForSeconds(0.01);
Destroy(gameObject);
if(other.gameObject.name!="Start"){
Destroy(other.gameObject);
targRMG--; //Only works once.
}if(other.gameObject.name=="Start"){
yield WaitForSeconds(2.4);
Application.LoadLevel(1);
}if(targRMG==9){
print("One down...");
}if(targRMG==8){
print("HOORAH!");
}if(targRMG==10){
yield WaitForSeconds(0.5);
print("Not refilling");
}
}