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 Collinbxyz · Jul 14, 2010 at 08:31 PM · timer-scriptendgameover

End Game When Time Is Up

How do you end the game when the time is up??? Here is my script right now.

private var startTime; private var restSeconds : int; private var roundedRestSeconds : int; private var displaySeconds : int; private var displayMinutes : int;

var countDownSeconds : int;

function Awake() { startTime = Time.time; }

function OnGUI () { //make sure that your time is based on when this script was first called //instead of when your game started var guiTime = Time.time - startTime;

 restSeconds = countDownSeconds - (guiTime);

 //display messages or whatever here -->do stuff based on your timer
 if (restSeconds == 60) {
     print ("One Minute Left");
 }
 if (restSeconds == 0) {
     print ("Time is Over");
     //do stuff here
 }

 //display the timer
 roundedRestSeconds = Mathf.CeilToInt(restSeconds);
 displaySeconds = roundedRestSeconds % 60;
 displayMinutes = roundedRestSeconds / 60; 

 text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds); 
 GUI.Label (Rect (43, 10, 100, 90), text);

}

How do I make it, so when the time hits 0, it takes them to a page that says: Game Over. (I will make the page and stuff) Please help! I am almost runner.

P.S. I will try to have the game on iPhone, so if you're interested on what you helped me with, the Game will be called Mountain Runner, and should be expected to be finished sometime this summer. Thx!

Comment
Add comment · Show 1
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 Cyclops · Jul 14, 2010 at 08:57 PM 0
Share

Similar to http://answers.unity3d.com/questions/15264/end-game-when-hits-water

1 Reply

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

Answer by Mike 3 · Jul 14, 2010 at 08:44 PM

Easiest way would be to use a new scene for it, alread set up how you want it:

if (restSeconds == 0) {
    Application.LoadLevel("Name Of End Game Scene");
}
Comment
Add comment · Show 2 · 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 Collinbxyz · Jul 14, 2010 at 09:31 PM 0
Share

sweet, thx i got it!!!

avatar image Collinbxyz · Jul 14, 2010 at 11:25 PM 0
Share

Okay, I did, sorry =}

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

1 Person is following this question.

avatar image

Related Questions

when mouse pass over a button,the console print some content 1 Answer

Gui.Button over another gui.button 1 Answer

counting destoryed objects 2 Answers

Need Help Ending A Game - Alphabet Game 1 Answer

Timer Pause and Reset Issue 2 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