I’m trying to use a stopwatch through fixed update to achieve more consistent delta Times, but the stopwatch is giving me 0’s whenever I push the effect project settings timeStep to 240 fps.
The current readings go in a pattern of
.0
.0
.0
.016
What’s happening here is that you’re learning how FixedUpdate really works.
It’s not, in reality, called every fixedDeltaTime seconds. It’s always called before Update is called, but if Time.time has crossed the “threshold” of a Time.fixedDeltaTime interval, then it calls FixedUpdate - sometimes multiple times, until the “fixed time” has caught up to the “game time”.
If you use Unity’s own timing mechanisms in the Time class, that won’t be an issue, because Unity fakes the values like Time.time so that the simulation has a fixed time interval. If in FixedUpdate you Debug.Logged the value of Time.time instead, it would indeed be going up at an even amount. And from FixedUpdate, Time.deltaTime will always return your fixed time step.
We’re using a analog data acquisition source and we want to acquire samples as fast as possible (240 Hz).
I figure that the solution to this problem is to have C# threads instead use their own Stopwatches to determine when to read from the analog source instead of FixedUpdate telling it when to read.
If you have a scenario like that, you’re definitely going to want the data-gathering going on in its own thread. Neither Update nor FixedUpdate will reliably be run at any particular time interval in a real-world clock sort of situation.
Yes that is what I am currently in the process of doing. Still learning a lot of Unity’s capabilities and the proper way to utilize the engine and the resources. It’ll take me a while to get everything over onto a new Data acquisition thread.
Currently trying to build to a Windows system. We’re trying to see if we can get a good enough refresh rate for a 240 Hz monitor or adapt the rendering to VR.