What would be the best way to implement a cutsom Time.time with double precision?
Just a small script with a public double property that has time += Time.deltaTime in Update? Or is FixedUpdate better? I would also have to set the priority of this script highest to always make it execute first, right?
Is there maybe some other way to access the internal double? Or an already existing solution (asset)?
Well the point of Time.time is to give you the time at the start of this frame, so FixedUpdate wouldn’t be useful for that. What are you trying to do that Time.time isn’t sufficient for? I’m guessing that converting DateTime.Now.Ticks to seconds will get you the precision you want.
Unfortunately Unity does not uncover Time.time as a double, it’s only a single.
If you want precision like that you’re going to need to setup your own timer. The simplest approach would just be to sum the deltaTime every Update onto your own double. But this value might stray over time from Time.time as I’m not sure how accurate deltaTime actually is.
What is it you’re attempting to do that requires this precision? With that information we may be able to suggest to you the best way to track it.
I’m simulating stuff thats very time dependant. I’m also calculating intervals where the low precision is even worse
I’m basically calculating times for the future and then compare them when the Time.time has come. Like if I move towards x for 14.3453 seconds what would my position be vs what my actual position was after Time.time passed 14.3453 seconds.
I’m having a similar problem but with less constrain. What I did was to accumulate the delta frame, then when it get over 1, store the difference with 1, accumulate an integer, then next frame add the difference back to the next delta on a reseted accumulator.