I have few animations that work similar to this:

IEnumerator MoveObjTo(GameObject obj1, GameObject ob2, float time)
    var start = obj1.transform.position.x;
    var end = obj2.transform.position.x;

    float passedPath = 0f;
    var s = end - start;
    float speed = (end - start) / time;
    while (passedPath < s)
        var ds = speed * Time.deltaTime;
        var newPos = obj.transform.position;
        newPos.x += ds;
        obj.transform.position = newPos;
        passedPath += ds;
        yield return new WaitForEndOfFrame();

It worked fine until I added this line to my code:

Application.targetFrameRate = 60;

After this, inside the Unity editor animation started to work 10 times faster (it's still OK on device). And I noticed that if I set targetFrameRate to the same FPS value as shown in the editor's Stats (400 FPS), to the animation speed is fixed.

If I print Time.deltaTime and ds inside this method, I'll get about the same values and it looks like Time.timeDelta is always 0.017, but with different targetFrameRate values that same 0.017 corresponds to different real time intervals.

I'll fix it by ifdefing the targetFrameRate setup, I'm just curious how this works.

  • \$\begingroup\$ Not sure if this is what's causing your issue but the Unity Editor only redraws the scene when it needs to. If you're not moving the viewport and nothing is updating, it won't re-render the editor view. As such, Time.deltaTime can vary wildly and may represent several seconds per frame. Are the fast animations purely in the editor view? Or also when in Play mode? \$\endgroup\$
    – Basic
    Sep 13, 2022 at 15:40
  • \$\begingroup\$ What version of Unity are you using? \$\endgroup\$
    – Kevin
    Sep 14, 2022 at 2:20
  • \$\begingroup\$ @Basic idk, I logged timeDelta in while cycle(so, every frame, I guess) and it was always about ~0.017 \$\endgroup\$
    – daedal99
    Sep 14, 2022 at 13:35
  • \$\begingroup\$ @Kevin it's 2021.3.1f1 \$\endgroup\$
    – daedal99
    Sep 14, 2022 at 13:36
  • \$\begingroup\$ Btw, DOTween animations working perfectly well. \$\endgroup\$
    – daedal99
    Sep 14, 2022 at 13:37

1 Answer 1


Some things you can check:

  1. Make sure you aren't changing Time.timeScale anywhere.
  2. Make sure you aren't setting Time.captureDeltaTime or Time.captureFramerate anywhere.
  3. See if you can update the Unity Editor to a newer version, in case it's a bug in the Editor.

You must log in to answer this question.

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