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 abhishekabz004 · Jun 12, 2015 at 02:31 PM · c#gametimepausetimescale

Couldn't resume once Time.timeScale is set to 0

Beginner here. In my game I have placed a pause method. The best ever method as far as I know to pause is to set Time.timeScale to 0. But the problem is I can't resume by setting it back to 1 as every other object in my game including codes got paused. Someone please help me with a replacement. My code also involves animator gameobjects.

also I want to know whether setting Time.timeScale to 0 would pause the System time Time.time or not.

Thanks in advance. :)

Comment
Add comment · Show 5
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 screenname_taken · Jun 12, 2015 at 03:41 PM 1
Share

What is the UI system you are using? I'm also placing timescale to 0, but i just have a function in a button and it sets it back to 1. I'm using the new UI that got introduced in Unity 4.6.

avatar image maccabbe · Jun 12, 2015 at 03:52 PM 1
Share

UnityEngine's Time.time is affected by Time.deltaTime. I recommend that you use Time.realtimeSinceStartUp if you want Time.time without it being affected by Time.deltaTime.

http://docs.unity3d.com/ScriptReference/Time-realtimeSinceStartup.html

avatar image abhishekabz004 · Jun 12, 2015 at 04:56 PM 0
Share

@screenname_taken I just used the pause button as a normal gameobject and not UI button. wouldn't it work then?

avatar image screenname_taken · Jun 12, 2015 at 08:32 PM 1
Share

@abhishekabz004 nnnoooooooyyysssnnnoooooo? Don't think so, but i guess it will depend on your implementation on the script. If you have something in Update, it won't i think but don't quote me on that :P.

avatar image abhishekabz004 · Jun 13, 2015 at 02:39 PM 0
Share

sorry :P btw. I have posted my code in the other answer. help me out if you find any mistake :)

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by sabish-m · Jun 12, 2015 at 06:06 PM

 #pragma strict
 
 function Paused(){
     
         Time.timeScale = 0.0;        
 }
 function Resume(){
 
         Time.timeScale = 1.0;
 } 
 function Quit(){
         Application.Quit();
 }
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 abhishekabz004 · Jun 13, 2015 at 02:44 PM 0
Share

I appreciate your help. :) But I already have my code. Its just that it is not working (resu$$anonymous$$g) once it gets paused. Here is my code.

public class pauseaction : $$anonymous$$onoBehaviour {

 public bool ispause= true;
 
 void Update () {

     if (Time.timeScale == 0) {
      //Time.timeScale =1;
      /* I even tried to change it this way. But still it wouldnt change once it got paused */
     }

 }

 void On$$anonymous$$ouseDown(){
     if (ispause) {
             ispause=false;
         Time.timeScale=0;
             
             } else {
         ispause=true;
         Time.timeScale = 1;
     }

 }

}

Correct me if I made some mistake. Thank you once again for helping me. :)

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

23 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Pause game that not using deltatime for movment 1 Answer

Pause Game When Function Is Enabled? 3 Answers

Stop force from being applied during pausescreen 1 Answer

Can't set Time.timeScale back to 1. 2 Answers

Distribute terrain in zones 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