Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Androxen255 · Feb 10, 2020 at 10:59 PM · physicstimescale

Time Scale and physics problem

My game contains photomode, where you can stop time. The problem is after I stop the time physics act incorrectly. I mean when some object where going down after bringing time to normal they suprisely are going up or other stupid direction. Why unity acts like that? Have you any idea how can I fix the problem?

Here is simple photo Mode controller:

void Update() {

     if (Input.GetKeyDown(KeyCode.RightArrow))
     {
         timeFactor += 0.05f;

         Time.timeScale = Mathf.Clamp(timeFactor, 0f, 1f);
         Time.fixedDeltaTime = Time.timeScale * .02f;

         timeTxt.text = Time.timeScale + "x";
     }

     if (Input.GetKeyDown(KeyCode.LeftArrow))
     {
         timeFactor -= 0.05f;

         Time.timeScale = Mathf.Clamp(timeFactor, 0f, 1f);
         Time.fixedDeltaTime = Time.timeScale * .02f;

         timeTxt.text = Time.timeScale + "x";
     }

     if (Input.GetKeyDown(KeyCode.Space))
     {
         timeFactor = 0;

         Time.timeScale = timeFactor;         
         Time.fixedDeltaTime = Time.timeScale * .02f;

         timeTxt.text = Time.timeScale + "x";
     }
 }
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 orionsyndrome · Feb 11, 2020 at 03:45 AM 0
Share

Now it's been a while since I tackled physics, but I think that by changing Time.fixedDeltaTime you're messing with the physics more than you should. It regulates the intervals at which FixedUpdate is called, and therefore you're probably inducing some undesired effects in however the forces and momenta are conserved and interpreted over time. From what I remember you need only Time.timeScale.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by rh_galaxy · Feb 12, 2020 at 01:03 AM

I don't think you should set "Time.fixedDeltaTime" all the time. It controls the rate of FixedUpdate() and you don't want to change that, leave it at 0.2 or set it to 0.1 but you are not supposed to change it every frame that you are doing now...

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 Androxen255 · Feb 24, 2020 at 08:04 PM 0
Share

Yeah and that was the problem, I don't know why, but it was good idea to set fiexdDeltaTime once :D

avatar image
0

Answer by corris_unity · Feb 12, 2020 at 12:36 PM

I copy-pasted this into a scene with a bunch of falling cubes and couldn't replicate the issue - stopping time made the cubes stop falling, and resuming time made them continue falling at the expected rate.

Can you provide a short video clip or something showing the incorrect behavior? And by any chance is there anything else in your scene that affects Time.fixedDeltaTime?

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

201 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 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 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 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 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 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 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 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 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

The Speed of Built APK 0 Answers

How to have realtime months/years pass in seconds 1 Answer

Force physics collision calculation (forced fixed update) 0 Answers

Bullet behaves strangely - TimeStep problem? 1 Answer

calculate time required if timescale is changed 0 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