Precise time dependend calculations

Hi everyone.
I am doing a simulator for educational purposes and I am trying to simulate a laser scanning system. These devices can make up to 2 million measurements per second. Laser distance measurement is not a problem, I do it with Line Trace by Channel.
Making 2 million calculations is a bit tricky. With scanning static objects, it is not a problem if the scanning time is not the same as in reality. So I can simply do it in several loops one by one until I reach 2 million measurements.
However, the problem becomes more tricky when I try to measure moving objects.
First of all, I need to make the movement of my object time-dependent and not tick-dependent. I can do that by using Delta Seconds from Event Tick to calculate the object position in every frame (in this example object only rotates):


In the same way, I can do a loop for laser measurements. The number of measurements will depend on the duration of the frame (delta seconds).

In general, everything works, but Delta Seconds has a precision of 0.001 s. And that causes the next problems:

  1. If object movement is based on delta seconds and I do thousands of micromovements for measurement - the position of my object will be not precise after a certain time.
  2. When doing loops for measurements I use Delta Seconds to calculate the exact number of loops per frame. But this number is always rounded, because Delta seconds is float and Loop needs integers. So after some time my number of measurements is different from programmed.
    After all of this my question is:
    Is there a way to get a time precision better than 0.001s in UE?

Did you try a timer? It fires at time interval, between frames - the direct benefit is that you no longer need to deal with delta time:

This has counted to 10k in 1s.

1 Like

That worked much better than with Delta Time! Thanks!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.