ok so i want to make it so when you destroy all the turrets in the level, it goes to the next level, but my script aint working
the script attached to the next level controler:
static var TotalTurretsDestroyed = 0;
var TurretsToDestroy = 1;
function OnTurretDestroyed ()
{
TotalTurretsDestroyed +=1;
if (TotalTurretsDestroyed == TurretsToDestroy)
{
TurretsToDestroy = 0;
Application.LoadLevel(2);
}
}
the script that destroys the turrets:
var explosion : Transform;
function OnTriggerEnter( hit : Collider)
{
if(hit.gameObject.tag == "wormProgectile")
{
Destroy(hit.gameObject);
var exp = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
NextLevel.TotalTurretsDestroyed += 1;
Destroy(gameObject);
}
}