unscaledDeltaTime not acting like deltaTime.

The script below is attached to a game object. When I run it the object teleports ahead and pauses for a split second before moving in the given direction. It doesn’t do the teleporting if I use Time.deltaTime instead of unscaledDeltaTime.

public class Transform_Movement : MonoBehaviour
{
Vector3 movement;

void Start()
{
    movement = new Vector3(2,2,0);
}

void FixedUpdate()
{
    transform.position += movement * Time.unscaledDeltaTime;
}

}

Why does it do this and how do I get it to stop the teleporting?

Time.unscaledDeltaTime appears to be unaffected by Time.maximumDeltaTime.

Compounded on this, when you first enter play mode, there’s usually a long hiccup during the first frame.

This means that if, say, the default maximumDeltaTime is ~0.33, that’s the value you’d see for deltaTime, whereas unscaledDeltaTime would be the actual time spent (let’s say 0.7 seconds, as an example of moving more than twice as far).

After that first long frame has elapsed, you’ll see the object having moved significantly further, but only because that’s more accurate to the actual time that has elapsed during that long frame.

I think I see the difference now. I’m going to try something to overcome that time lapse. Thanks.

I didn’t get what you meant by teleporting, sorry, so the answer by @Eno-Khaon is likely correct. But I see that you use it in FixedUpdate() where Time.fixedDeltaTime should rather be used. It may run several (or fewer) FixedUpdate() per Update() depending on Fixed Timestep in the settings.


Also I have found a way around it that includes setting Time.timeScale to 0 first in Update(), do all my setup (Awake(), Start() for other objects, and keep doing more setup for a few frames in Update()), and then after say 30 frames in Update, set Time.timeScale to 1, and begin the game for real. No teleporting occurs.

Good to know. I might try putting it in a coroutine and see what happens.