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 MrRstar · Apr 08, 2011 at 06:24 PM · pausing

resuming Time.timeScale Problems

So i have a pause button working on a sidescroler. it pauses and resumes the game using Time.timeScale. the problem is that when i resume the game, everything moves and reacts slower. i can't pick up the powerups (collision based) and the enemy takes a sec to react to the controler passing him, do damage, and stop while hitting him.

Here is the script for the pausing. the powerups and enemy movement are on different scripts:

var thePauseButton = GUI.Toggle(Rect ((Screen.width)-((theButtonWidth*3)), theButtonSpace*-1, theButtonWidth, theButtonHeight), thePauseButton, "Pause");

if(thePauseButton) { print("Pause"); PauseTheGame (0); gamePaused = true; }

if (Input.GetKey (KeyCode.Escape) && gamePaused) { print("Resume"); //Time.timeScale = 1.0; PauseTheGame (1.0); gamePaused = false; }

function PauseTheGame (theRateScale) { Time.timeScale = theRateScale; Time.fixedDeltaTime= theRateScale; theRate = theRateScale; }

On a side note, i was under the impression that a timescale of 0 would pause everything in the scene. but the enemy still moves and i can still instiantiate prefabs (a bullet) but it won't move.

Comment
Add comment · Show 4
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 MrRstar · Apr 08, 2011 at 06:27 PM 0
Share

Sorry about the code, i can't seem to get it to format correctly.

avatar image Mike 3 · Apr 08, 2011 at 07:21 PM 0
Share

There's a little button with 1s and 0s on, select all of your code then click that

avatar image MrRstar · Apr 08, 2011 at 07:27 PM 0
Share

i did, but it wouldn't format it any better than how i have it here for some reason. i've done it before, it just doesn't like me today.

avatar image efge · Apr 08, 2011 at 08:31 PM 0
Share

But it likes me :-) (formatted the code)

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by efge · Apr 08, 2011 at 08:44 PM

Maybe it is because you are mixing Ints with Floats? You could try to declare the variable "theRateScale" and call it accordingly:

PauseTheGame (0.0);

function PauseTheGame (theRateScale : float) { ... }

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 MrRstar · Apr 08, 2011 at 10:05 PM 0
Share

i did have theRate declared as and int. but after i changed it, it didn't make a difference.

avatar image
0

Answer by Victor 1 · Apr 09, 2011 at 01:31 AM

Insted of Time.timeScale you can use a varibles that checks if the game if pause or not, and if it paused it dosent move charater,enemies etc.

void OnPauseGame () { paused = true; }

void OnResumeGame () { paused = false; }

void Update (){ if(!paused){ //do stuff } }

Comment
Add comment · 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

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

disabling a script (MouseLook) 5 Answers

Coroutine randomly stops and continues after pausing and unpausing game 2 Answers

ManaBar plus pause 1 Answer

Problem with Pause and WaitForSeconds 2 Answers

i have some pausing errors 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