How to accurately measure Time

Hey, you may use GetAccurateRealTime node.

You can find details about it here:

Cheers

hmm interesting question. maybe there is an advanced programmatic approach but I would take a simple problem solving approach.

Since you know the deltatime, and you should be able to know how fast your vehicle was moving when it crossed the finish line, if you can compare the vehicle frontal extent position with the finish line position, you will be able to measure how much of the distance was crossed between frames and use the last known speed to determine how long during the transition the actual finish happened. Should work in theory.

Imagine a simple scenario where there are only 2 frames sampled. over these 2 frames, the object moves 10 units, but the “finish line” is actually at 5 units. Lets say it takes 1ms to render to two frames.

With default behavior using overlap events, this will basically tell you it took 1ms to cross the finish line, when in reality it only took 0.5ms.

If you know that the final distance is 10units, finish line is 5 units, and the last frame told you that the object velocity is 10units per ms, by dividing that by the number of units we know that the object crossed the finish line at halfway through the frame. Make sense?

its really no different than the classic math question “two trains head towards one another…”

The issue is that no matter how accurate the time you get is, it can only be sampled at the resolution of the frame rate. With some math you can find the exact intersection.

Hi,

i have a racing game and i want to record the lap times precisely (down to ms).
Currently i have a Blueprint (finish line) that stops the time recording in it’s overlap event.
The problem is that this is dependent on framerate.
E.g. if i the game runs @ 10 fps the recorded time will have a 100ms accuracy and even if it runs @ 60 fps it’s accuracy is 16.6ms, etc …
So is there a way to measure time more precisely (and independent of fps)?

Cant you just accumulate the deltatime for each event tick between starting and finishing the lap?

So have a boolean condition for timerOn which is set when you start the lap, and if timerOn is set to true on your EventTick add deltatime to your laptime variable, when you cross the finish line set timerOn to false and your laptime variable should contain the time for the lap in milliseconds.

Another option would be to write a C++ utility class that exposes current date time to your blueprint. You could then store time lap started and time lap finished and then calculate difference?

Hoped i missed something - no luck i guess :wink: Will make it as suggested.
And thanks for the (insanely) fast answer - awesome support!

Thats not a bad way to track time in general, but it doesn’t help solve the problem of figuring out times on a smaller granularity than frame times. What if something happens “in between” frames? you gotta solve the point of intersection.

Maybe there is a similar approach like you use it with Continuous Collision Detection?