if (hitPoints <= 0) {
// Display Game Over and Stop the game.
if (gameoverText) {
gameoverText.active = true;
Time.timeScale = 0;
}
}
This code shows the game has pause after it’s game over. I am now wanting to make a GUItext as a replay button, but still wondering how to script to make the application to restart once click the replay GUItext ?
function OnMouseDown() {
Application.LoadLevel(1); // Or whatever level
}
Hmm i tried putting this script into it, but when i click on the button it brings me to another scene >_<". Well as u stated “// or whatever level” , i know i should type it to somewhere to my level but i need some explanation a little on how it works. Tried play around but i still can’t make it to load my level instead of other level.
function OnMouseDown () {
Application.LoadLevel(0);
}
Saying Application.LoadLevel(0) will load the very top level in the build settings. Application.LoadLevel(1) will load the second level in the build settings. The build setting are under “File>>Build Settings…”
You can also use the scene name you’ve assigned the “level” as well if it’s easier to remember (it is for me in case I move the scene order around later. Thus …
function OnMouseDown () {
Application.LoadLevel(start);
}