- Home /
Standalone builds run very fast on some computers?
For some reason on some computers my builds are running at around 1.5x - 2x times the speed. This is a huge problem and I have no idea where this problem may be rooted. I'm setting the target FPS (via Application.targetFrameRate) but that doesn't seem to do anything. Everything in the game is dependent on Time.deltaTime so I can't see a reason why this would change computer to computer. And it is consistent on the computers that it's fast and not fast on.
Any potential leads on where this issue could have stemmed from will be useful. Thanks a ton!
What is it exactly that is going quickly?
Have you tried printing the current Time.time to GUI to see it its normal?
If animation is the problem you may need to play with Fixed Time Step
Lerps? Like Lerp(A, B, 0.05)? Even if you toss in a time.deltaTime, the math is wrong (correct math involves solving a polynomial, I think.)
The entire game is going quickly. It's effectively as if I'd set the Time.timeScale to 1.5 or 2. This is a very difficult thing for me to test since it's only happening on a few computers, $$anonymous$$e not being one of them, so no, I haven't tried printing Time.time. And I have practically no animation in the game, everything is scripted movement. And yes, things like Lerps and $$anonymous$$oveTowards are also fast, since it appears as if time.TimeScale is getting warped... on ONE computer. haha
Also, being it's only occurring on a few computers, but most are fine, I can assume my math is fine and this is a Unity setting or performance variable I have to tinker with. Unless most think thats wholly untrue.
How do you know it's running too fast if you don't have enough access to the computers to print debug information. Have you actually seen it running too fast first hand?
Answer by clunk47 · Dec 02, 2013 at 01:35 AM
Most modern NVIDIA and AMD GPUs have a control panel. Be sure VERTICAL SYNC is enabled in the GPU's control panel / settings. This usually syncs the game's framerate with your desktop's refresh rate. Also have a look at Unity's reference for settings of vSyncCount HERE.
I'm not really a graphics guru or anything, but I wonder if setting to every vBlank for 60Hz and setting to every other vBlank for 120Hz would work? Try something like this and let me know if it helps at all.
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
Resolution res;
void Start()
{
res = Screen.currentResolution;
if(res.refreshRate == 60)
QualitySettings.vSyncCount = 1;
if(res.refreshRate == 120)
QualitySettings.vSyncCount = 2;
print (QualitySettings.vSyncCount);
}
}
Looking into that a bit more it turns out that it's because the monitors being used are 120hz. Apparently moving the game to a second monitor (not 120hz) fixed it. Interesting. I'm not sure what to do with that info exactly... is this tied to the vSync still? If I remove vSync entirely (or add an option for it in the options) do you think that should fix it? Thanks btw, this is leading to a solution! = D
Looks like that worked! vSync level 2 runs fine on 120hz monitors! Thanks a ton man.
Sweet!!! First time I had to deal with this so had my fingers crossed lol. So glad I was able to help :D
Answer by Spinnernicholas · Dec 02, 2013 at 01:51 AM
This is usually caused when frames are being used to control flow rather than time. If you are do things that depend on time in Update() without taking time into account, things like this can occur. If you want to time things by frame, you can move your code to FixedUpdate() instead, but it is usually a better idea to use Time.deltaTime.
//Frame rate Dependent(Bad)
Update()
{
//Move 1x/frame
transform.position += new Vector3(1,0,0);
}
//Frame rate Independent
Update()
{
//Move 1x/sec
transform.transform.position += new Vector3(1,0,0) * Time.deltaTime;
}
It looked like you might have, but you didn't post any code. It is a very common rookie mistake.
It makes sense that Application.targetFrameRate does nothing if everything is controlled by Time.
Yup, but when you're grasping at straws... Either way, I have all sorts of slow down on death, and pausing, etc going on during the game, so everything HAS to be time dependent. Turns out (as I state above) it's linked to the refresh rate of the monitor. $$anonymous$$oving the game from a 120hz monitor to a non-120hz monitor fixed it.
I use Time.deltaTime in almost every update function but when i build my game to mac_standalone it runs way more slower than windows_standalone. And as long as i knew a macbook air screen refresh rate is standart 60Hz. Since the testing app runs on an editor, can i say its all about my machine's hardware capability or is this the same performance i will get when i build it to an ios device? Cause i dont have a licence to test it for now and at some point im gonna have to continue developing game on a mac to publish it for ios devices.
Your answer
Follow this Question
Related Questions
Is there a way to speed up the game more than 100 times? 1 Answer
How can I make a GUI element move independently of the frame rate? 1 Answer
Real elapsed time since frame begin 1 Answer
CPU usage, fps and colliders 0 Answers
FPS alternate each time I run my application. Sometimes it's 100, sometimes its 500... 1 Answer