Hi
I'm creating a game with different levels. I have a Main Menu and also a level selection menu. I also have 2 scripts. I'd like to know how it is possible to only select the levels in the level selection menu that you already have finished. I've tried it with static variables but now I know that static variables reset if you switch a scene.
This is my Move Around Script:
var speed = 6.0;
var JumpSpeed = 8.0;
var gravity = 20.0;
private var dead = false;
private var moveDirection = Vector3.zero;
private var grounded : boolean = false;
var myClip : AudioClip;
static var Level1Enabled = true;
static var Level2Enabled = false;
function OnControllerColliderHit(hit: ControllerColliderHit)
// Fall To Dead
{
if(hit.gameObject.tag =="Fallout")
{
dead = true;
HealthControl.LIVES -=1;
}
//End Level
if(hit.gameObject.tag =="End1")
{
Level2Enabled = true;
Application.LoadLevel(3); // selection menu
}
}
Script atached to the gui.text in the selection menu for level 2.
var level2Finished = MoveAround.Level2Enabled;
function OnMouseEnter()
{
if(level2Finished)
{
renderer.material.color = Color.green;
}
}
function OnMouseExit()
{
renderer.material.color = Color.white;
}
function OnMouseUp()
{
if(level2Finished)
{
Application.LoadLevel(4);
}
}