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 CubePhysics · Apr 18, 2016 at 06:16 PM · 2drotationrigidbodypausetorque

torque speeding up when the game is unpaused

I have a rigidbody2D that is meant to rotate. When i press the pause button the timescale is set to 0.0f and everything stops like it is supposed to. But when I unpause the game and timescale goes back to 1, all the objects that should be rotating speed up really fast and then go back to their normal speed after a second. I have also noticed that the longer the game is paused and then unpaused the objects spin much faster.

Rotation

     public float torque;
     void Update () {
                 rb.AddTorque(torque, ForceMode2D.Force);
         }

Pause

     public void Pause()
     {
         if(isPaused == false){
             Time.timeScale = 0.0f;
             isPaused = true;
         }else if(isPaused == true){
             Time.timeScale = 1.0f;
             isPaused = false;
         }
     }

Can someone please help me fix this so that when the game is unpaused, the objects are rotating at the same speed as they were before the pause.

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 CubePhysics · Apr 18, 2016 at 08:52 PM 0
Share

bump. please help me.

2 Replies

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

Answer by RiQQ92 · Apr 19, 2016 at 02:46 AM

For unity physics and timeScale to work properly you should use FixedUpdate() instead of Update() as Update() is called anyways even if timeScale is 0. As in your case you are adding torque every frame in Update() but 'timeScale = 0' prevents unity from calculating physics and drag to lower the torque force.

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
avatar image
0

Answer by FlightOfOne · Apr 18, 2016 at 08:56 PM

Try this:

  void Update()
     {
         if (!isPaused)
         {
             rb.AddTorque(torque, ForceMode2D.Force);
         }
     }

Also, note that you are adding 'torque' every frame. Either you need to put angular drag to counter this or only add torque when you need to, otherwise it will compound and spin faster and faster.

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

78 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

Related Questions

How to convert Torque Stabilizer to RigidBody2D? 1 Answer

Move prefab in the direction its facing (2D) 2 Answers

Make sprite turn with rigidbody2D velocity 0 Answers

Raycasting around a gameObject while it's rotating 1 Answer

BOX ROTATE ONLY ON X AXIS When Look AT!!HELP! 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