How Would I Make The Game Go To Next Level After i Hit 1000 Points?

Hey Guys :slight_smile:

I’m Currently Working on a FPS/Gothic/Zombie Game and its really turning out great! I Would Like To Implement Some Sort Of Script When i reach 1000 Points On The Score Manager it will Show a screen saying Level Completed and give me the option to go to next level (scene). I’m Using The FPSKitV1.2 There score manager is what I’m using ATM. if that’s any help.

FPSKit is a great tool to help Unity users - but it’s not an official Unity tool, thus most UA posters don’t know it in depth (me included).

But maybe you can adapt the basic idea to your game: try to locate the script where the points are accumulated (ScoreManager?). Supposing you’ve found the script, and there’s a variable called score that holds the current score, you should add the necessary code to it - something like this:

// declare this variable outside any function:
var showDialog: boolean = false;

// add this line to Update:
function Update(){
  if (score > 1000) showDialog = true;
  ... (remaining Update code, if any)
}

// create function OnGUI (or modify it, if already existing):
function OnGUI(){
  if (showDialog){
    var next = Application.loadedLevel + 1; // calculate next level index
    if (next < Application.levelCount){ // if there exists a next level...
      if (GUI.Button(Rect(200,100,300,50),"Load next level")){ // show the button
        Application.LoadLevel(next); // and load it if button pressed
      }
    }
  }
  ... (remaining OnGUI code, if any)
}

EDITED: Since you’ve posted the ScoreManager script, things became a lot easier: you don’t need the variable showDialog neither the Update modification - all you need is to modify the OnGUI function as follows:

...
function OnGUI(){ 
  GUI.skin = mySkin;
  var style1 = mySkin.customStyles[0];

// ***** JUST ADD THIS CODE: *************
  if (currentScore > 1000){
    var next = Application.loadedLevel + 1; // calculate next level index
    if (next < Application.levelCount){ // if there exists a next level...
      if (GUI.Button(Rect(300, Screen.height - 110,280,60),"Load next level")){ // show the button
        Application.LoadLevel(next); // and load it if button pressed
      }
    }
  }
// ***************************************

  GUI.Label (Rect(40, Screen.height - 80,100,60)," SCORE :");
  GUI.Label (Rect(100, Screen.height - 80,160,60),"" + currentScore, style1);
  ...

var score : int;
var a : int = 0;
scoreText : GUIText;

function Start(){
   score = 0;
}

function OnGUI(){
   scoreText.text = ""+score;
}
function Update(){
   score++;
   if(score > 1000){
     a = 1;
   }
   if(a == 1){
     Application.LoadLevel("LevelName");
   }
}

None of this is working… Keep getting so many errors. Guess this is too advanced for my noob skills. if anyone thinks they can help add me on msn, AusAndrew@hotmail.com thanks :slight_smile: