Hello, I’ve searched for the answer of this question but I could not find it. The question is really simple, I have in one scene this script:
function OnGUI(){
if(GUI.Button(Rect(267,0,77,33),"Next Wave")){
Application.LoadLevel("Asteroid");
}
}
And in another scene this one:
var IsSpawning : boolean = false;
var Asteroid : Transform;
var WaveNumber = 1;
static var Score : int = 0;
static var Lives : int = 3;
static var HighScore : int = 0;
static var EnemyCounter = 0;
function Start(){
WaveFunction(WaveNumber);
}
function Update(){
if(Lives <= 0){
if(Score > HighScore){
HighScore = Score;
}
Application.LoadLevel("ScreenLoss");
}
if(EnemyCounter == 0 && !IsSpawning){
Application.LoadLevel("ScreenShop");
}
}
function UpdateWave(){
WaveNumber++;
WaveFunction(WaveNumber);
}
function WaveFunction(Wave : int){
var EnemysInThisRound = Wave * 4;
IsSpawning = true;
for(var i = 0 ; i < EnemysInThisRound; i++){
var position = Vector3(Random.Range(-6, 6), 12, 0);
Instantiate(Asteroid, position, Quaternion.identity);
yield WaitForSeconds(Random.Range(1, 1.5));
EnemyCounter++;
}
IsSpawning = false;
}
My question is how do I start the UpdateWave function when I press the NextWave Button in the first scene?
Thank you -Nelis