0
\$\begingroup\$

When I set the Time.timeScale in unity very high, many scripts seem to do werid things (because of the high deltaTime they use for their logic).

Is there an option to let unity split up one update - call with a high deltaTime to multiple calls per frame, each with a lower deltaTime?

\$\endgroup\$
2
  • \$\begingroup\$ Can you move any of the behaviour to FixedUpdate, which can be called multiple times per frame? And have you looked into the custom PlayerLoop for options there? \$\endgroup\$
    – DMGregory
    Nov 12, 2018 at 12:25
  • 1
    \$\begingroup\$ Or, to attack this from another angle, can you describe why you're setting Time.timeScale so high? If you're implementing some kind of time shift / fast-forward mechanic, there might be other alternative solutions that are more stable, so try describing the feature this ultimately needs to serve. \$\endgroup\$
    – DMGregory
    Nov 12, 2018 at 14:06

1 Answer 1

-1
\$\begingroup\$

It's impossible.

This is because of interpolation. The point of Time.deltaTime is to interpolate in real-time, as opposed to by frame, which it does by giving a number smaller than 1 (in normal circumstances) that is the part of a second it took between the current and previous frame.

Because by-design, Update() is called per-frame, after redrawing the screen. You can't call it more times per second as that would mean upping the framerate, and when your computer is going at the fastest it can handle, well, there's your problem.

When you have lots of things in your scene, your framerate goes down, because the computer can't work fast enough to render everything.

It is also worth noting that modifying Time.timeScale is the same as simply the same as using Time.unscaledDeltaTime * Time.timeScale (or Time.deltaTime * someScale, when Time.timeScale = 1).


When I set the Time.timeScale in unity very high, many scripts seem to do werid things (because of the high deltaTime they use for their logic).

The way you get a smooth effect is that when there is enough frames, the intepolation is un-noticible, in the same way that computers update their screens faster than our eyes can visually see. Take for example, old-style film and animated flip-books.

When you have a high Time.timeScale, or any large number multiplied into Time.deltaTime, there simply isn't enough frames in a second to make it look smooth.

It is like the difference between when you attempt to flip a flipbook animation at the fastest you can, and flipping through each page every second.


Is there an option to let unity split up one update - call with a high deltaTime to multiple calls per frame, each with a lower deltaTime?

On a any computer, there's nothing you can do because, well, the computer is already working at its limit. Sure you could try to get a super-beefy computer to get higher framerates, for really large numbers, 60 and 200 frames aren't going to make a difference.

At that point (also a common technique used in cinematography, since everything is capped to 24 frames, for the most part), you would probably want to apply motion blur, but that itself has its own set of problems.

If you want to simply call Update() four times, it is just the same as Time.unscaledDeltaTime * Time.timeScale * 4, which only worsens the interpolation effect.

Unless that large number represents a small number of pixels on screen, you may want to decrease the speed your object moves.

\$\endgroup\$
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .