[ad_1]

this may not be constant for various framerates – is that proper?

Time.timeScale is impartial of framerate. Unity will proceed to attempt to render on the identical framerate no matter time scale. Nevertheless, time scale can have an effect on efficiency and not directly trigger inconsistent habits affected by framerate:

Rising the time scale additionally will increase the variety of physics updates that have to be carried out per second of actual time, except you then enhance the Time.fixedDeltaTime property. Rising the fixedDeltaTime will have an effect on the accuracy of the physics and ultimately will result in unusual and undesired habits.

If in case you have any costly code which runs at common intervals, rising the time scale will make this costly code run extra usually. As a easy instance:

personal IEnumerator UpdatePath() {
    var delay = new WaitForSeconds(.1f);
    whereas (true) {
        yield return delay;
        // For the sake of instance, as an example this perform is pretty gradual:
        CalculateNewPath();
    }
}

On this instance, we calculate a brand new path each 0.1 seconds of in-game time. At 60fps and the default time scale of 1, that may imply that we calculate the trail each sixth body. Now think about we set the time scale to six. Now we’ll have to calculate the trail each sixtieth of a second in actual time, which suggests we’re now working this costly perform each body!

This instance illustrates one other problem – as an example {that a} participant’s system does not have good efficiency and might solely handle 30fps. This implies at a time scale of 1, they’d run CalculateNewPath() each 3 frames. At a time scale of 6, they would want to run CalculateNewPath() each half of a body (since WaitForSeconds() does not work like that, the perform would nonetheless solely get known as as soon as per body, now each 0.2 seconds of scaled time)! One of these problem can power you to place all your sport logic into FixedUpdate() features to make sure the code runs on the right interval even when the framerate is low.

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *