- Home /
How to change different levels in 1 scripts?
As the title, for example, I have total 5 levels in 5 scenes, "scene1" "scene2" "scene3"... When I destroy all the enemy I will move to next scene, is there anyway to use just 1 script which I named it "levelChange" to move from scene1 -> scene2 and then from scene2 -> scene3? Or I must adjust the script for each scene?
a similar question was asked here
http://answers.unity3d.com/questions/132329/current-scene-number.html
Answer by RedCherryStudios · Aug 08, 2013 at 02:17 PM
Hmmm, i think i have a fix for you.
Lets say that you already have a boolean for if all the enemys are dead called "AllDead"
Var levelToLoad = 0;
var allDead : boolean = false;
function Awake(){
levelToLoad +=1;
}
Function Update (){
if(allDead)
{
application.loadLevel(levelToLoad);
}
}
Set level to load as your starting level and make sure the game object with this script has
"DontDestroyOnLoad (transform.gameObject);"
Hope this helps! :)
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
getting a variable from another script problem 1 Answer
How to execute a Skript global? 2 Answers
Script help please 1 Answer