Yeah, I’m back after only 4-1/2 hours sleep. Beyond the whole forklift parent-child problem, I have an easier one this AM. If someone would volunteer, I’d be grateful.
I have a gamecontroller object at the beginning of the game not being destroyed.
I have three levels … the only difference between them is the time remaining. Easy 180 seconds, medium 120 seconds, hard 75 seconds.
And yet, foolishly, I’m trying to maintain three identical complex scenes.
So, instead of the having the Easy/Medium/Hard options on the splash screen take you to three different scenes I’d simply like to declare the seconds remaining in the game controller and load one scene with the the time remaining display set to the proper seconds depending on which “level” a user selected.
This means keeping my variable (timeRemaining) as you go from the the splash screen to the game screen. Easy enough, but this is the code I have in the DisplayTimer GUIText object …
var secondsLeftEasy = 181.0;
var submitStuff : Transform;
// here's where we display the time remaining
var timershow : GUIText;
private var done : boolean = false;
function Update () {
// start time
Time.timeScale = 1;
// if time is less than 0 end scene and go to scoring scene
// mathf.floor forces it to round to 0
timershow.text = "Time Remaining = " + Mathf.Floor(secondsLeftEasy);
secondsLeftEasy -= Time.deltaTime;
if (secondsLeftEasy < 0) {
timershow.text = "Time's up!\nEnter your name and\nclick Submit Score.";
Time.timeScale = 0;
MoveItemsIn();
}
}
// move the enter name filed and submit score button in from off camera
function MoveItemsIn ()
{
submitStuff.position = Vector3 (1.022799,-2.656232,-1.859603);
}
See the “var secondsLeftEasy = 181.0;” part? I have three of these scripts, one for each level. I’d rather have a single level with one DisplayTimer item that knows which of the three levesl you chose in an earlier scene.
How do I modify the gamecontroller script and the above script to do this?
Gamecontroller script relevant part to load one of the levels shown as follows …
function LoadEasy () {
// Load the Easy level
Application.LoadLevel ("leveleasy");
}
Thanks and good morning everyone!