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 Carl 2 · Apr 26, 2011 at 12:54 PM · guitimer

How do I get remaining time to display on screen?

Hi guys, I've never done a timer in Unity before and I was wondering if anyone could help me out with getting time to display on the screen?

This is the script I'm working with:

var seconds = 60; private var textMesh : TextMesh;

function Start () { textMesh = GameObject.Find ("Timer").GetComponent(TextMesh); textMesh.text = seconds.ToString(); InvokeRepeating ("Countdown", 1.0, 1.0); }

function Countdown () { if (--seconds == 0) CancelInvoke ("Countdown"); textMesh.text = seconds.ToString(); }

I've applied the script to an empty game object and I added a text mesh to the object, but I don't know how to display the time on-screen so the player knows how much time they have left.

Also I'm guessing it's a very simple case of telling the timer to load a different level when it gets to 0? (I'd like it to go to a Game Over screen!)

Thanks in advance guys :).

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

Answer by Justin Warner · Apr 26, 2011 at 01:32 PM

Make a game object in the scene called Timer, and have a Text Mesh on the game object, it should work then...

To load a new level: http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html

Hope this makes sense.

Comment
Add comment · Show 5 · 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 Carl 2 · Apr 28, 2011 at 12:55 PM 0
Share

Thanks for the reply. I shall try that and see if it works. Thankyou :)

avatar image Carl 2 · Apr 28, 2011 at 01:00 PM 0
Share

Unfortunatley I'm still having the same problem, nothing is appearing on the screen at all.

Didn't think it'd be this much hassle to get the timer to appear on the screen :/

avatar image Carl 2 · Apr 28, 2011 at 06:58 PM 0
Share

I found a work around. I changed it from Text$$anonymous$$esh to GUIText and that worked fine :)

avatar image Justin Warner · Apr 29, 2011 at 02:41 AM 0
Share

Lol, that's good. Sorry, I couldn't think of anything =).

avatar image Carl 2 · Apr 30, 2011 at 03:05 PM 0
Share

That's quite alright. Thankyou for the assistance :)

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

No one has followed this question yet.

Related Questions

Lerpz Escapes question 1 Answer

hide gui.label after an event 1 Answer

3Dplatformer tutorial GUI script - adding a timer GUI 0 Answers

timer problem 1 Answer

Timer issue - bool value not setting timer to false? 1 Answer


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