• 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 MKayJay · Jan 21, 2018 at 11:24 PM · physicsrigidbodytimescaleslowmotion

Slow motion for Physics game

I recently decided to add slow motion to my game, which can be activated at will by the player. I have no problem getting the desired effect, but my problem is either the physics or performance... let me explain:

The Physics It seems that the most common way to do slow motion is to adjust Time.timeScale, Time.fixedDeltaTime and Time.maximumDeltaTime, as I do in the snippet below, where .02f and .15f are the default values for fixedDeltaTime and maximumDeltaTime respectively.

 Time.timeScale = enableSlowMo ? .2f : 1;
 Time.fixedDeltaTime = Time.timeScale * .02f;
 Time.maximumDeltaTime = Time.timeScale * .15f;

This looks really good, but the downside is that because I make changes to fixedDeltaTime, the physics calculations are wrong, and the objects more differently in slow motion than at normal speed.

The Performance Issues My second solution was to just change Time.timeScale, this gives very jagged movement of most objects while in slow motion though. As such, I decided to enable interpolation on all rigidbodies, and voila, I have my desired result. The problem is though that in some of my levels I have several hundreds of rigidbodies (It's a physics game after all) which drastically affects performance when interpolation is enabled on all rigidbodies, especially in cases where a lot of collisions occur.

My own thoughts are that there may be some way to "calculate" my way out of the issues generated by the first solution, without cutting too much into performance, but I'm still coming up short.

In short, my question is: Are there better ways to do this, than the two I've mentioned?

Any input or hints would be greatly appreciated - Thanks for your time.

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 Harinezumi · Jan 22, 2018 at 12:31 PM 0
Share

I don't think you should modify Time.fixedDeltaTime, especially that it is already affected by Time.timeScale (see note in scripting reference).
I think the second way is the correct approach, but unfortunately I don't know how to optimize it.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by KittenSnipes · Jan 22, 2018 at 05:43 AM

@NasarethMekuri

Well Brackeys seems to get smooth results so I am just going to send you his video rather than explain it because he explains it much better than I can.

Here's the video: Video Link

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 MKayJay · Jan 22, 2018 at 11:11 AM 0
Share

@$$anonymous$$ittenSnipes Thanks for your reply.

Brackeys solutions is more or less the same solution as the first one I mentioned myself, the only difference is his approach and that he doesn't change the maximumDeltaTime. - The end results are the same, the issue is just not that obvious in his example. The problem is if I shoot an object forward using physics, as soon as it collides with something, the resulting trajectory is different between the slowed timescale and the normal, because of the changes to fixedDeltatime.

As I mentioned in my post, I have a "fix" which is not changing fixedDeltaTime and using Interpolation on all my rigidbodies, but it's fairly expensive in my case.

I was hoping for alternatives to the two suggestions, or at least modifications to them :-)

avatar image
0

Answer by Wyano · Jul 28, 2021 at 10:35 PM

Same issue here, still looking for a solution :(

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

150 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

Related Questions

Add force in slow motion 1 Answer

Everything in slowmotion except player: How to adjust fall/jump speed of character accordingly? 1 Answer

Physics behave weirdly after timeScale change 1 Answer

TimeScaling & Rigidbody problem 0 Answers

Slow Time for a single Rigid Body 5 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