Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 AlanGameDev · Jul 18, 2015 at 03:00 AM · fixedupdatetimescalesyncsimulationtimestep

Is it possible to tick the fixed timestep manually or increase the timescale beyond 100?

Hello there.

I'm making an RTS game that uses NavMeshAgents and also Physics, and since these are internally managed/ticked in the fixed timestep, I decided to tick my logic in FixedUpdate() so they are in sync, everything is working wonders so far, but I'm trying to implement a "fast forward" function that is supposed to run as fast as the computer is capable of; at first I thought it was simply going to be a matter of increasing the timescale until the framerate drops considerably, but the timescale is capped at 100x, what is really slow for my game and doesn't even stress too much my computer. I can't call FixedUpdate() on all MonoBehavious manually because I need my logic to be synced with AI and Physics.

So, is there a way to either 'tick' the fixed timestep manually, or increase the timescale to a bigger value?

Thank you in advance.

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
0
Best Answer

Answer by AlanGameDev · Jul 18, 2015 at 02:13 PM

I couldn't find any better solution so I had to tweak all the parameters and use a timescale of 0.1 for 'normal' speed, so I could increase it up to 1000*, it wasn't as easy as multiplying all the values by 10 though, the gravity for example is around -300y, and the AI agents had to be fine tweaked, specially the acceleration and angular speed which had to be cranked substantially up. The end result is far from perfect, but I think overall the simulation is acceptable for that style of game.

To speed up as much as the computer is able to handle (not exactly though, because there's still overhead), I'm simply increasing (programmatically of course) the timescale until the framerate (i.e.: the graphics update) drops to a very low level. I think you can use that in various cases, for example, if you want to simulate many years passing rapidly, you could perhaps disable the camera and just show a progress bar, so the framerate could drop to <1 per second without problems I think (not tested though).

I'd like to have an official word on why the timescale is capped @ 100* though.

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
1

Answer by Bunny83 · Jul 18, 2015 at 03:35 AM

It seems you're confusing some things a bit. First of all FixedUpdate represents the internal physics update. Lowering the fixedtime step will increase the fixed update rate, however it won'd have an effect on the simulation speed of the physics system. Everything is scaled by Time.fixedDeltaTime. (Note: Time.deltaTime is equal to Time.fixedDeltaTime when used from inside FixedUpdate).

So when you increase the fixed update rate your physics calculations just get more precise since it does smaller steps each update. You can set it to "0.001" and you will get 1000 fps for FixedUpdate. Unity will by default drop FixedUpdate calls if the catching up with the actual time takes too long and the frametime exceeds 0.3333 seconds (max allowed time step). At that point you would only have around 3 real fps.

If you want to speed up your game you should increase Time.timeScale.

If your game logic isn't time based, you might want to use your own seperate fixed update function. For this purpose i've written the CustomFixedUpdate class which allows you to have as many fixed update routines as you like. They can run at any frequency you like.

Finally i've never seen Unity to "cap" my FixedUpdate calls (unless the load is too heavy --> 3fps or worse). I just added a counter to my FixedUpdate and every second i print and reset the counter and i get a constant value and it works fine even with 10000 fps (however in my test i don't use any physics ^^).

Comment
Add comment · Show 3 · 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 AlanGameDev · Jul 18, 2015 at 03:49 AM 0
Share

Thank you for your answer. The question was confusing before but I've fixed that. I'm not talking about lowering the fixed timestep, but increasing the timescale OR somehow ticking the fixed step manually, however, I think you're correct that the physics uses the timescale (and the real time), so ticking the fixed timestep manually would simply improve precision ins$$anonymous$$d of increase the simulation rate. As I said, I can't manually step my logic because it is tied to the internal stepping, thus, if there's no way to increase the timescale further, I'm afraid there's no way to do what I want... I wonder why the timescale is capped at all. A solution I could think of would be to use a timescale of 0.1 for normal speed, and adjust the settings (AI speed, gravity, etc.) to achieve something believable, this way I could speed up the game to 1000x the normal speed, but that's going to be a pain to do.

avatar image AlanGameDev · Jul 18, 2015 at 04:25 AM 0
Share

@Bunny83 the curious part is that the timescale isn't capped on the lower end, it can go below zero, but not above 100, what doesn't make much sense to me.

avatar image AlanGameDev · Jul 18, 2015 at 02:14 PM 0
Share

@Bunny83 It seems there's no better way than using a lower value for normal speed, so I answered my own question and accepted that. I upvoted your answer though. Thank you.

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

23 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

Related Questions

How to speed up simulation time without distorting results 0 Answers

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

How to prevent Navmesh Agent from overshooting destination with high Time.TimeScale? 1 Answer

Fixed timestep... 1 Answer

Time.timeScale = 0 can't stop FixedUpdate() 3 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