Tuesday, September 13, 2022
HomeGame Developmentunity - Setting goal framerate adjustments animation pace in editor, whereas Time.deltaTime...

unity – Setting goal framerate adjustments animation pace in editor, whereas Time.deltaTime stays the identical


I’ve few animations that work much like this:

IEnumerator MoveObjTo(GameObject obj1, GameObject ob2, float time)
{
    var begin = obj1.rework.place.x;
    var finish = obj2.rework.place.x;

    float passedPath = 0f;
    var s = finish - begin;
    float pace = (finish - begin) / time;
    whereas (passedPath < s)
    {
        var ds = pace * Time.deltaTime;
        var newPos = obj.rework.place;
        newPos.x += ds;
        obj.rework.place = newPos;
        passedPath += ds;
        yield return new WaitForEndOfFrame();
    }
}

It labored effective till I added this line to my code:

Software.targetFrameRate = 60;

After this, contained in the Unity editor animation began to work 10 instances sooner (it is nonetheless OK on machine). And I observed that if I set targetFrameRate to the identical FPS worth as proven within the editor’s Stats (400 FPS), to the animation pace is fastened.

If I print Time.deltaTime and ds inside this technique, I am going to get about the identical values and it appears to be like like Time.timeDelta is all the time 0.017, however with completely different targetFrameRate values that very same 0.017 corresponds to completely different actual time intervals.

I am going to repair it by ifdefing the targetFrameRate setup, I am simply curious how this works.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments