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
5
Question by BitMiller · Dec 03, 2010 at 01:11 PM · physicssmoothtimescale

If timeScale is lowered how can I aviod to get the physics simulation choppy?

A simple script attached to a gravity dragged falling cube:

Time.timeScale=0.1;

And it's fall isn't smooth. Yuk! How could I smooth it out?

(Using Unity 3.1)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
14

Answer by duck · Dec 03, 2010 at 03:32 PM

You need to reduce the physics timestep ( Time.fixedDeltaTime ) value by a corresponding amount.

If I'm doing slow-motion, I usually do something like this:

Time.timeScale = slowMotionSpeed;
Time.fixedDeltaTime = slowMotionSpeed * 0.02f;

0.02 is the default physics timestep, so this code means the physics maintains its smoothness in proportion to the current timeScale - so you'll get 50 physics steps per frame, regardless of the timescale.

Comment
Add comment · Show 6 · 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 Louis-N-D · Apr 24, 2014 at 11:24 AM 0
Share

This was super helpful! Thank you.

avatar image thekingofclubs · Aug 25, 2014 at 04:11 PM 0
Share

What should I do when restoring the Time.timeScale to 1.0? Do I need to do something like Time.fixedDeltaTime = slow$$anonymous$$otionSpeed * 1.0f? Or does fixedDeltaTime automatically come back to normal when timeScale is 1.0?

avatar image thekingofclubs · Aug 25, 2014 at 08:01 PM 0
Share

I got it... when restoring timeScale to 1.0, set fixedDeltaTime to 0.02 which is the default value, or whatever value you have set under Edit - Project Settings - Time - Fixed Timestep.

avatar image CiberX15 · Mar 12, 2017 at 07:57 PM 0
Share

Seems like you also need to set Time.maximumDeltaTime to whatever your time scale is.

 Time.timeScale = slow$$anonymous$$otionSpeed;
 Time.maximumDeltaTime = slow$$anonymous$$otionSpeed;
 Time.fixedDeltaTime = slow$$anonymous$$otionSpeed * 0.02f;

When I was using slow motion on ragdolls without that line, the ragdolls would begin to float up into the air and would shoot off like rockets when I turned slow mo off.

Reference: http://www.41post.com/4258/program$$anonymous$$g/unity-slow-motion-and-rigidbody-behavior

avatar image b1naryatr0phy CiberX15 · Mar 29, 2017 at 10:08 AM 0
Share

@CiberX15

"Seems like you also need to set Time.maximumDeltaTime to whatever your time scale is."

That's not what the article is saying. It's saying you need to factor both maximumDeltaTime and fixedDeltaTime by the same value.

         newTimeScale = Time.timeScale/slowFactor;
         Time.timeScale = newTimeScale;
         Time.fixedDeltaTime = Time.fixedDeltaTime/slowFactor; //<<<<<<<<<<<<<
         Time.maximumDeltaTime = Time.maximumDeltaTime/slowFactor;//<<<<<<<<<<

(Worth pointing out that this method wont work properly if you want to lerp the scale over time.)

avatar image Domvel · Oct 17, 2018 at 09:34 AM 0
Share

If I also change the fixedDeltaTime my car wheels rotates fast without dragging force. In other words: The physics behavior is weird / glitchy. If I only change the timeScale value it is choppy. But I think I have to increase the physics interpolation ins$$anonymous$$d of change fixedDeltaTime. Is there a variable for the physics interpolation? $$anonymous$$aybe the interpolation attribute of each rigidbody. Or is there a global variable?

avatar image
5

Answer by Waffle1434 · Mar 09, 2018 at 11:59 PM

Another Solution would be to enable Interpolation on rigid bodies. This more or less costs the same, but guarantees smooth results.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

calculate time required if timescale is changed 0 Answers

Cannonball physics? 1 Answer

Physics behave weirdly after timeScale change 1 Answer

Time Scale and physics problem 2 Answers

Physics calculations vs TimeScale vs FixedDeltaTime 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