- Home /
how to reset time
i've written very little local high score script with PlayerPrefab and when i restart Level time doesnt reset. there is the script and if you need you can use ;)
 var points : int;
 var targetGuiText : GUIText;
 var targetGuiText1 : GUIText;
 var Renderer;
 private var gldepth = -0.5;
 private var startTime = 0.1;
 private var tris = 0;
 private var verts = 0;
 private var savedTimeScale:float;
 private var pauseFilter;
 private var score : int;
 
 function OnTriggerEnter(hit : Collider)
 {
  if(hit.gameObject.tag == "Finish")
  {
  targetGuiText.enabled = true;
  targetGuiText1.enabled = true;
     savedTimeScale = Time.timeScale;
     Time.timeScale = 0;
     AudioListener.pause = true;
     if (pauseFilter) pauseFilter.enabled = true;
  Finish();
  }
 }
 function Start() {
  targetGuiText.enabled = false;
  targetGuiText1.enabled = false;
 }
 
 function Update()
 {
  targetGuiText.text = ("Highest Score: " + PlayerPrefs.GetInt("points"));
  targetGuiText1.text = ("My Score is: " +points /2);
   if(Input.GetKey(KeyCode.Home)){
 Application.LoadLevel(Application.loadedLevel);
 }
  print("I finished in: " +points); 
  Time.timeScale = 1;
 }
 function Finish(){
 //Save this high score da ar damseivebelis dedas sheveci me :D 
 if(points > PlayerPrefs.GetInt("points")){
 PlayerPrefs.SetInt("points", points);
 }
  if(Time.time <= 50) //if you make it before 90 seconds
  {
    points += 60; //add points
  }
  if(Time.time <= 40) //if you make it before 90 seconds
  {
    points += 70; //add points
  }
  if(Time.time <= 30) //if you make it before 90 seconds
  {
    points += 80; //add points
  }
  if(Time.time <= 20) //if you make it before 90 seconds
  {
   points += 90; //add points
  }
  if(Time.time <= 10) //if you made it before 50 seconds
  {
   points += 100; //add points
  } 
 }
 
I deleted your swearing. Please act professionally if you want to be treated with respect.
sorry Graham i wrote this script for me and i forgot to delete these words
Answer by Graham-Dunnett · Apr 16, 2013 at 09:07 PM
Time.time is measured from the start of the game, not the start of the level. 
you were right ! now i'm using Time.timeSinceLevelLoad and it works perfectly.
Answer by Negagames · Apr 16, 2013 at 09:10 PM
Create two new variables, one which will always do the following:
 if(timeFollow < Time.time){
      timeFollow++;
      timeUse++;
 }
and while timeFollow is always counting up, and never behind, use timeUse as your reset-able variable.
Your answer
 
 
             Follow this Question
Related Questions
timer that can be reset 1 Answer
creating a timed function 3 Answers
Unity how to find load time? 1 Answer
How To Reset Timer on a Collision (C#) 0 Answers
How to realize accurate time counter (millisecond precision) 3 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                