- Home /
Android update math at higher hz?
So I am still bothered by a question I have not really found the answer to yet. The question is: Is there any possible way to go beyond 60 fps on an Android device - I don't care if I see 12 fps. All I care about in this situation is that the scripts and objects interact and loop thousands of fps in an empty project environment. I could calculate a thousand math problems in a single loop, but that use has limitations. I literally want the script to loop thousands of fps like it already does on pc's, but it seems all unity's docs care about is visual fps (the fps you can see in the pixels - not the fps of math loops/object interactions and variables).
Answer by meat5000 · Jul 04, 2014 at 09:09 AM
Use FixedUpdate and change the FixedTimeStep.
Hmm.. not sure that works, but I'll try a build to my android later today.
FixedUpdate runs independent of framerate. Adjusting FixedTimeStep defines how many times the script will be executed every second.
Last time I tried, it could not go faster than void update() which can not seem to get past 200 hz on my s4.
Then you need to change $$anonymous$$aximum Allowed Timestep. This throttles FixedUpdate execution when experiencing low framerate.
Yes, it does work. However keep in $$anonymous$$d that if you too much calculations inside FixedUpdate and the CPU can't keep up that rate, the (visual) FPS will drop down to the maximum allowed timestep. FixedUpdate is actually called right before Update, but if the Update rate is too low, FixedUpdate is simply called multiple times per visual frame to keep up the constant rate. On the other hand if the fixed rate is lower than the visual rate, FixedUpdate is skipped in some interleaved frames.
For example with a fixed rate of 50fps and a visual rate of 100 fps, FixedUpdate is only called every second Update call.
If you set the fixed rate to 1000 but you only have a visual update rate of 25 fps, Unity will call FixedUpdate 40 times each frame.
Here's a webplayer i made to explain how it basically works.
Answer by Bunny83 · Jul 05, 2014 at 11:55 PM
FixedUpdate is the easiest way to run certain code at a fix rate. However increasing the fixed rate also affect the physics system since it runs along with FixedUpdate. If you want to use physics but also have your code run at a higher fix rate, you can use my CustomFixedUpdate. It does almost the same thing Unity does to ensure a certain call-rate per second.
You can set any rate you like: once an hour or 10000 times a second.
Note: FixedUpdate (as well as my implementation) doesn't actually run at a "fix" rate but is "fixed" in the sense of "corrected". The scripting environment in Unity runs in the main thread and therefore it's affected by the overall frame time. The solution to have a (statistically) constant rate is to let the system catch up with the current time within one frame.
So at a (visual) framerate of 100fps a "fixed" update at the rate of 10000 is called 100 times each (visual) frame. If the frame rate drops to 20fps, the fixed update is now called 500 times per frame.
Keep in mind that as soon as your over all frame time exceeds Time.maximumDeltaTime (which is 0.3333 by default == 3fps) Unity will clamp Time.deltaTime to that value which will make your game actually run slower. If your hardware can't keep up that rate there's nothing you can do against it. The same way you can't copy 3TB onto a 1TB HDD. The only way is to buy a new HDD which has enough space ;)
If I could, I would thumbs up that! Very nice solution for keeping the built in physics available.
Your answer
Follow this Question
Related Questions
iOS @ 30fps: what does Unity/Update do during/if spare time? 0 Answers
Android 6.0 Marshmallow creates black bar along bottom of screen. 4 Answers
Mobile Game Patcher? 1 Answer
Why is the Motorola Xoom (Dual Core) slower than the Samsung Galaxy S (Single Core)? 2 Answers
Is changing 60 FPS into 30 FPS affects time in coroutines? 0 Answers