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 haim96 · Jul 31, 2013 at 06:12 AM · gametimepausetimescaledeltatime

Pause game that not using deltatime for movment

Hi all!

i know there is a lot of answers about pausing a game, i read most of them and in most of them the answer was: "use time.timescale = 0". it seems to me like the right way but there is one problem, it doesn't work! i tried to figure out why and i come to conclusion that it might be related to the fact that my game object is move by code like:

 void update()
 {
 if (move = "yes")
    {
    x+=1 ;
    object.transform.position.x+x;
    }
 }
 ........

it's not the real code, just a sample of what i have done. but the point is that there is no use of deltatime here... so my questions are:

A. am i right? B. is there any other method to pause game? some integrated function like: "application.pause" ... or something...

thanks!

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

Answer by gregzo · Jul 31, 2013 at 06:56 AM

Update is still called when timeScale is set to 0. Else, how would you unpause the game? It is good practice to multiply by Time.deltaTime when moving/rotating/applying force, as it makes movement frame rate independent and allows pausing.

Consider this: a cube moves by 1 unit per frame. At 60 fps, it will move 60 units per second. At 30 fps, 30 units per second. If frame rate is unstable, your cube's movement will be erratic as well.

Now, if the cube moves by 60 units per second multiplied by Time.deltaTime, whatever the frame rate the speed will stay constant.

And, because of that deltaTime multiplication, if timeScale is set to 0, the cube will stop.

Comment
Add comment · Show 5 · 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 haim96 · Jul 31, 2013 at 07:20 AM 0
Share

so according to this the answer to A is that i'm right. but i will have to check this with my code... i guess it should be:

 (object.transform.position.x+x) * time.deltatime

and about B, does time.timescale=0 is the formal way to pause game?

avatar image gregzo · Jul 31, 2013 at 07:27 AM 0
Share

Transform.position.x + speed*deltaTime ( it is the the mouvement which should be multiplied by deltaTime, not the position).

Aout B, yes, most people use timeScale to pause afaik.

avatar image haim96 · Jul 31, 2013 at 07:46 AM 0
Share

right! ok... and since my gameobject should move along X OR Z axis (with turns of 90 degrees ) it wan't effect this kind of movement but make it more smooth and allow me to pause it. i will test it later today and mark this question as resolved if it work well. thank you so far.

avatar image haim96 · Jul 31, 2013 at 03:17 PM 0
Share

O$$anonymous$$, i added the Time.deltatime and now the game pause. problem is now the movement far from being smooth. i'm testing on tablet device and the movement seems jerky then smooth. i have a camera that follow my object. tried the lerp like other topics suggest but it doesn't help... any idea?

avatar image haim96 · Jul 31, 2013 at 06:54 PM 0
Share

O$$anonymous$$! i resoled also the jerky movement by put the camera follow in: Void LateUpdate() ins$$anonymous$$d of Update().

thanks for the help!

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

15 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

Related Questions

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

TimeScale = 0 crashes Unity 1 Answer

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

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

Pause, Unpause 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