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
0
Question by dalekandjedi · Jul 21, 2012 at 10:01 PM · guitimer

Countdown Timer

Hey I need help

I would like a timer for my game but its like a game show timer so like say you have 3 mins to complete something then when 10 secs are left the timer comes up on the screen i would like something like that but i have no idea how to do it

Comment
Add comment
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

1 Reply

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

Answer by AlucardJay · Jul 21, 2012 at 10:16 PM

check my answer on this question : http://answers.unity3d.com/questions/279434/problem-restart-time-by-key.html

and this : http://answers.unity3d.com/questions/231521/how-to-display-data-in-an-array.html

all the information you need to do this are in those 2 answers =]

also : http://lmgtfy.com/?q=unity+countdown+timer

EDIT : here is what you're after ....

 #pragma strict

 var theTimer : float = 0.0;
 var theStartTime : float = 120.0;
 var showRemaining : boolean = false;

 function Start() 
 {
     theTimer = theStartTime;
 }

 function Update() 
 {
     theTimer -= Time.deltaTime;

     if (theTimer < 10) 
     {
         Debug.Log("TEN SECONDS LEFT !");
         showRemaining = true;
     }

     if (theTimer <= 0) 
     {
         Debug.Log("OUT OF TIME");
         theTimer = 0;
     }

     if ( Input.GetKeyUp(KeyCode.G) )
     {
         Debug.Log("Resetting");
         theTimer = theStartTime;
         showRemaining = false;
     }
 }

 function OnGUI() 
 {
     var text : String = String.Format( "{0:00}:{1:00}", parseInt( theTimer / 60.0 ), parseInt( theTimer % 60.0 ) ); 

     if (showRemaining)
     {
         GUI.Label( Rect( 10, 10, Screen.width - 20, 30), text );
     }
 }



Comment
Add comment · Show 4 · 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 dalekandjedi · Jul 21, 2012 at 10:26 PM 0
Share

Thats not what im looking for i have a script for a menu to come up but i need a script so it say 10 seconds left then starts counting down

avatar image AlucardJay · Jul 21, 2012 at 11:02 PM 0
Share
 var showRemaining : boolean = false;

 ... in update
 if (remainingTime < 10secs)
 {
     showRemaining = true;
 }

 ... OnGUI
 if (showRemaining)
 {
     GUI.Box( Rect(0,0,100,20), remainingTime.ToString() );
 }
avatar image dalekandjedi · Jul 21, 2012 at 11:11 PM 0
Share

so does that timer come up when its 10 seconds to 3 $$anonymous$$s?

avatar image AlucardJay · Jul 23, 2012 at 01:24 AM 0
Share

comments, thoughts ????

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

GUIText not working properly with a timer. 1 Answer

Timer that can be accessed in multiple scenes 1 Answer

Texture Importer 3 Answers

targeting desnsity inside buoyancy script 0 Answers

Stand alone player 0 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