I am currently trying to make a Slider that smoothly goes from 0f to 100f, taking 100 seconds.
On my current way of making it work, that looks like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class swordui : MonoBehaviour
{
public Slider swordslider;
public float valuee;
public float speed = 0.01f;
public bool commit;
public void Awake()
{
commit = false;
valuee = 100f;
}
public void settozero()
{
valuee = 0f;
}
public void commitmoment()
{
commit = true;
}
public void Update()
{
swordslider.value = valuee;
if(commit == true)
{
valuee = Mathf.Lerp(swordslider.value, 100f, speed);
if (swordslider.value == 100f)
{
commit = false;
}
}
}
}
but this causes it to slow down by the end of the countdown. When I try to change it to:
valuee = Mathf.Lerp(0f, 100f, speed * Time.deltaTime);
it only counts up to 1, and then stops lerping.
How can I make it fully count from 0f to 100f, taking 100 seconds to do that, and without stalling by the end?