When all objects with a certain tag has been destroyed, load the next level!

Ok here’s what I’m trying to do:
I want to load another level when -all- gameObjects (actually there are only three gameObjects) with the tag “Player” get destroyed!

I think it should take two scripts to do it, one for counting gameObjects and the other for executing. Unfortunately, I’m not good at writing scripts, not good at all.

make a script called levelComplete and attach it to an empty gameobject anywhere or to ur char or w/e

var cont : int;
var levelNumber : String;

function Update(){
	if (cont == 2){
		Application.LoadLevel("levelname"+levelNumber);
		}
}

and at the script where u destroy ur gameObjects add this line
when they r destroyed

levelComplete.cont += 1;

You need to make a kind of “Manager” in this manager you will have a value that is linked with your number of player like “PlayerAlive”.

And you have a public function like “APlayerIsDead”.

In you Player script before he gets destroyed, you call “APlayerIsDead”.

In “APlayerIsDead” you reduce by one “PlayerAlive”. When “PlayerAlive” is 0 you Load your next level.

“I’m not good at writing scripts, not good at all” - Then go learn! Do tutorials etc. You’re going to need to know how one way or the other right?

In the mean time here is code that does what you want:

	void Update () 
	{
		if(GameObject.FindGameObjectsWithTag("Player").Length <= 0)
			Application.LoadLevel("LevelName");
	}