How can i reset the level in Project?

Hi All,

I worked on simple project in that some levels are there.

In that there is restart button. Actlly my problem is when i click my scene that is feeded perfeclty if i comes back and goes to that same scene that is resume only i don’t know that is not started from first.

my code is like this:

var isQuit=false;
function OnMouseEnter () {
renderer.material.color = Color.green;
}
function OnMouseExit () {
renderer.material.color = Color.red;
}
function OnMouseDown()
{
// if we clicked the play button
if (this.name == “Quit”)
{
// load the game
Application.Quit();
}
else
if(this.name==“Phet”)
{
Application.LoadLevel(1);
}

else
if(this.name=="PM")
{
Application.LoadLevel(2);
}
else
if(this.name=="SP")
{
Application.LoadLevel(3);
}
else
if(this.name=="Back")
{
Application.LoadLevel(1);
}
else
if(this.name=="Restart")
{
Application.LoadLevel(2);
}
else
if(this.name=="Back1")
{
Application.LoadLevel(2);
}
else
if(this.name=="Restart1")
{
Application.LoadLevel(3);
}

}

thanks

1 Answer

1

First your question makes sense but your description of your problem is very confusing. If you want to make it where it restarts the level, Just add this to your script:

var RestartLevel : String;

and then fix at line 16 function:

if(this.name=="Restart"){
  Application.LoadLevel(RestartLevel);
}

Hope that helps you.