Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-1
Question by lasha_an · Apr 16, 2013 at 08:59 PM · timetimerreset

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
  } 
 }

 
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Graham-Dunnett ♦♦ · Apr 16, 2013 at 09:05 PM 2
Share

I deleted your swearing. Please act professionally if you want to be treated with respect.

avatar image Negagames · Apr 16, 2013 at 09:07 PM 0
Share

You missed one on line 42.

avatar image lasha_an · Apr 17, 2013 at 04:41 PM 0
Share

sorry Graham i wrote this script for me and i forgot to delete these words

2 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lasha_an · Apr 17, 2013 at 04:40 PM 1
Share

you were right ! now i'm using Time.timeSinceLevelLoad and it works perfectly.

avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lasha_an · Apr 16, 2013 at 09:17 PM 0
Share

thank you very much. i exactly needed that

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges