Time.DeltaTime Bug

Hello everbody, I have a score (int) with Vector.Lerp and a Level Bar with Vector3.Lerp. My goal is to show them both in the Gameoverscreen after another. But if I try to enable the Level Bar after I check that the score has now been Displayed the Vector3.Lerp of the Level Bar Ignores Time.DeltaTime and just jumpes to his targetPosition.

My Code looks something Like this:

void Update () {
        score=Vector3.Lerp(score,target_score,Time.deltaTime);//Calculates a smooth Score Display
        score_text.text=(Mathf.RoundToInt(score.x)).ToString();

         //I tried to disable the score_text when (score == target_score) and enable the Xp but Then the error appears
       
        //Shows Xp running smooth
        showxp = Vector3.Lerp (showxp, showTargetxP, Time.deltaTime);
        FillBar.fillAmount = showxp.x / (Level * 100.0f);
        if (XpAdd != 0) {
            if (FillBar.fillAmount > 0.995f) {

                Level++;
                LevelText.text = "LEVEL " + Level;
                LevelUp ();
            }   
        }  
    }

void LevelUp(){
        int LevelGoal = Level * 100 - BaseXp;

        if (XpAdd < LevelGoal) {
            showxp = new Vector3 (BaseXp, 0);
            showTargetxP = new Vector3 (BaseXp + XpAdd, 0);

            BaseXp = BaseXp + XpAdd;
            XpAdd = 0;
        } else {
            showxp = new Vector3 (BaseXp, 0);
            showTargetxP = new Vector3 (Level * 100, 0);

            XpAdd = XpAdd - LevelGoal;
            BaseXp = 0;
        }
            
    }

Thank you in advance

You need to iterate on Time.deltaTime. When lerping, 0 will return “a” and 1 will return “b”. The issue is that Time.delta will always return the difference in time from this frame to the last. So as @JedBeryll said, 60 frames per second 0.01666. So you will never actually lerp from 0 → 1.

So with below you will use “animationTime” to determine how long you want it to take to fully do your lerp. Keep in mind because this is in Update its just going to begin when your object turns on so you will probably need to add handling of when this counter should start(unless you want it to start how you already have it).

private Vector3 score;
    private Vector3 target_score;
    private Text score_text;
    private Vector3 showxp;
    private UnityEngine.UI.Image FillBar;
    private Vector3 showTargetxP;

    public int Level { get; private set; }
    public int XpAdd { get; private set; }
    public Text LevelText { get; private set; }
    public int BaseXp { get; private set; }

    private float animationTime = 3.0f;
    private float totalTime = 0.0f;

    void Update()
    {

        float lerp = totalTime / animationTime;

        score = Vector3.Lerp(score, target_score, lerp);//Calculates a smooth Score Display
        score_text.text = (Mathf.RoundToInt(score.x)).ToString();

        totalTime += Time.deltaTime;

        //I tried to disable the score_text when (score == target_score) and enable the Xp but Then the error appears

        //Shows Xp running smooth
        showxp = Vector3.Lerp(showxp, showTargetxP, lerp);
        FillBar.fillAmount = showxp.x / (Level * 100.0f);
        if (XpAdd != 0)
        {
            if (FillBar.fillAmount > 0.995f)
            {

                Level++;
                LevelText.text = "LEVEL " + Level;
                LevelUp();
            }
        }
    }


    void LevelUp()
    {
        int LevelGoal = Level * 100 - BaseXp;

        if (XpAdd < LevelGoal)
        {
            showxp = new Vector3(BaseXp, 0);
            showTargetxP = new Vector3(BaseXp + XpAdd, 0);

            BaseXp = BaseXp + XpAdd;
            XpAdd = 0;
        }
        else
        {
            showxp = new Vector3(BaseXp, 0);
            showTargetxP = new Vector3(Level * 100, 0);

            XpAdd = XpAdd - LevelGoal;
            BaseXp = 0;
        }

    }