Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
1
Question by Justin Warner · Dec 15, 2010 at 11:53 PM · timescalemenupausetimescale

Pause menu... Isn't pausing everything...

//This is the code that wont stop executing.... var Monster : GameObject[]; function Start() { for ( var i = 0; i < Monster.length; i++ ) { Instantiate ( Monster[i], transform.position, transform.rotation ); yield WaitForSeconds ( 2 ); } }

//This is the move script: var target : Transform; var speed = 0.0f; var times = 0;

function Update () {

 if(!target)
 {
     target = GameObject.FindWithTag("House").transform;
 }

 var targetRotation = Quaternion.LookRotation(target.position - transform.position, Vector3.up);
 transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 100);
 if(times == 0)
 {
     speed = speed/2;
     times++;
 }
 transform.Translate(0, 0, speed);

}

//This is my pause script: var savedTimeScale;

function Update() { if ( Input.GetKeyDown ( "escape" ) && Time.timeScale == 0 ) { UnPauseGame(); }

 if ( Input.GetKeyDown ( "escape" ) &amp;&amp; Time.timeScale != 0 )
 {
     PauseGame();
 }

}

function PauseGame() { savedTimeScale = Time.timeScale; Time.timeScale = 0; AudioListener.pause = true; print ( "Paused" );

 //Show the picture.

}

function UnPauseGame() { Time.timeScale = savedTimeScale; AudioListener.pause = false; print ( "UnPaused" );

 //Take away the picutre.

}

The "Monsters" that are made keep moving.

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
4
Best Answer

Answer by Statement · Dec 16, 2010 at 01:07 AM

Pause menu Isnt pausing everything

The "Monsters" that are made keep moving.

transform.Translate(0, 0, speed);

You don't include delta time.

When timeScale is set to zero the game is basically paused if all your functions are frame rate independent.

transform.Translate(0, 0, speed * Time.deltaTime);

Update is still getting called regardless of Time.timeScale (FixedUpdate is not). Maybe you want to make an early return in case timeScale is 0.

If you lower timeScale it is recommended to also lower Time.fixedDeltaTime by the same amount.

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 Justin Warner · Dec 16, 2010 at 02:14 AM 0
Share

Thank you very much! Didn't know that... Guess that also shows how to keep things to still move (Environment objects).

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

How to Appease a pause menu in a game that changes it's time scale? 1 Answer

Pause menu doesn't pause everything 0 Answers

hi i just got the ultimate fps camera and it is not compatible with pausemenus 0 Answers

Timecale=0 stops joystick. can it not? 1 Answer

Couldn't resume once Time.timeScale is set to 0 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