• 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 halo · Sep 27, 2011 at 05:03 PM · timetimerpause

pause timer or player using Time.timeScale

hi guys i have a game manager script that i manage to pause the game when my player collide with an object by using Time.timescale but is there a alternative ways that i can pause only the timesystem and the game continue running if not then pause the game but the timesystem contiune running?

gamemanager.js

function Update(){

//if(isPaused == false){

if(!Paused){

Paused=false; } else {

Time.timeScale = 0;

Paused=true;

}

if(Input.GetButtonUp("Jump")){

Time.timeScale = 1;

Paused=false;

     //starttime = Time.time;
 
     //time += Time.deltaTime;
 
     OnGUI();
     }
 }
 

function OnGUI () {

Debug.Log("OnGUI");

 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");
 
     restSeconds = 0;
 
     Application.LoadLevel("2");
     //do stuff here
 Paused = true;
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 Julien-Lynge · Sep 29, 2011 at 12:44 AM 0
Share

I think you misunderstand timescale. Timescale is the speed that time passes within your game - it is intrinsic to the game itself.

What exactly are you trying to do, and why isn't changing the timescale working for you?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by henry96 · Sep 29, 2011 at 01:33 AM

I don't think there is other way to pause the default time system without using Time.timeScale. However, if you make your own time countdown or something else you can pause them. You can make a boolean to check if a pause button is pressed or not. If it is, then stop your script from subtracting the number of time.

if (!isPaused) {

restSeconds = countDownSeconds - (guiTime);

}

However if you want the game paused but the time continues ticking. Then you can disable all the components that you want to stop except the time by using this line of code

gameObject.GetComponent ("name-of-the-script").enabled = false;

Hope this helps. Good Luck!

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 Julien-Lynge · Sep 29, 2011 at 01:48 AM 0
Share

You can stop all your scripts that way, but be warned that this won't actually pause your game. For instance, if you have any objects with rigidbodies they will continue to move under physics.

avatar image henry96 · Sep 29, 2011 at 02:18 AM 0
Share

I agree!!!

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Timer-function which calculates how long an enabled script is running yet? 1 Answer

Is It Bad To Have Your Jump In Update()? 3 Answers

Unity3D Timer. 1 Answer

Pause Game When Function Is Enabled? 3 Answers

How to pause a game? 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