Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 jpthek9 · Jan 07, 2015 at 09:13 PM · pausefixedupdatetimescale

Stopping FixedUpdate

In my lockstep multiplayer game, I run specific simulations in FixedUpdate that need to be stopped under certain circumstances (I.e. in case of high latency). Normally, I'd use Time.timeScale = 0 but this is not possible because my coroutines would be affected, something that I need to run continuously. Can I stop FixedUpdate without using Time.timeScale? Would there be any glitches if I set Time.fixedDeltaTime to Mathf.infinity?

Comment
Add comment · Show 2
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 richyrich · Jan 08, 2015 at 02:28 PM 0
Share

Could you not just pause some of the coroutines while allowing the rest to continue?

http://forum.unity3d.com/threads/how-to-pause-any-coroutine-according-to-your-global-pause-state.68303/

avatar image jpthek9 · Jan 08, 2015 at 04:39 PM 0
Share

Yes :D Or invoke repeating

2 Replies

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

Answer by jpthek9 · Jan 08, 2015 at 04:41 PM

The solution is using a boolean to control FixeDUpdate, something very controllable by me. Then I can use a coroutine or invoke repeating to keep the package sends.

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 Bas-Smit · Aug 30, 2016 at 09:53 AM 0
Share

Hi jpthek9, I need to run a specific amount of fixed updates, would you $$anonymous$$d elaborating on what you mean by "using a boolean to control FixeDUpdate"?

avatar image
1

Answer by 3dmihai · Aug 30, 2016 at 10:20 AM

You can use a variable to check if a certain is met and execute the code. If the condition is not met - this is the case when you don't want to execute the code - set the variable to false. For example:

 // ...
 public static bool shouldExecute;
 // ...
 void FixedUpdate() {
 if (shouldExecute == true) {
      // your code within FixedUpdate
 }
 }

This way you can access shouldExecute variable from anywhere like this: ClassName.shouldExecute and set the value to true or false. I hope this helps.

Comment
Add comment · Show 2 · 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 Bas-Smit · Aug 30, 2016 at 10:31 AM 0
Share

Thanks for the response, but I need to control the amount of physics steps, its not about my code...

avatar image selind1 · Sep 22, 2021 at 12:39 PM 0
Share

You do not have to write == true in the if statement. Just write the var or !var

 public static bool shouldExecute;
  // ...
  void FixedUpdate() {
     if (shouldExecute) {
       // your code within FixedUpdate
     }
  }










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

29 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

Related Questions

Pause game on Start doesn't quite work 1 Answer

Unity 3.5.7 - 4.2 upgrade: Changing Time.timeScale causes OnTriggerExit & OnTriggerEnter handlers to fire 1 Answer

How do I pause my game? 24 Answers

Can't set Time.timeScale back to 1. 2 Answers

Best practice for countdown timer on game resume 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