Hello,
I am confused on how to store the data, Basically i have a script that times your lap, what i want to know is how do i save the time and use it as a best lap time and store it and be able to use it on multiple scenes
thanks
the timer
var timerInSecond = 0;
private var levelTimer = 0.0;
private var updateTimer = false;
var currentTime;
var style : GUIStyle;
var soundFile : AudioClip;
function Start()
{
updateTimer = true;
levelTimer = 0.0;
}
function Update()
{
if (updateTimer)
levelTimer += Time.deltaTime*1;
/// float to int
timerInSecond = Mathf.Round (levelTimer);
currentTime = levelTimer;
}
function LevelEnded()
{
updateTimer = false;
///Save Time
PlayerPrefs.SetInt("Time In Second", timerInSecond );
}
function OnTriggerEnter(box : Collider){
if(box.gameObject.tag == "box"){
Debug.Log("timerfinished");
updateTimer = false;
GetComponent.<AudioSource>().PlayOneShot(soundFile, 1.0);
}
}
function OnGUI () {
GUI.Label(new Rect(20,20,400,90), "Time = " + levelTimer,style );
GUI.Label(new Rect(20,150,400,90), "Boost",style );
}
How i change levels
function OnTriggerEnter (other : Collider) {
Application.LoadLevel ("level9");
}